Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

function addChar ( input , character ) { if ( input . value = = null | | input.value = = 0 )

function addChar(input, character){
if(input.value == null || input.value =="0")
input.value = character
else
input.value += character
}
function cos(form){
form.display.value = Math.cos(form.display.value);
}
function sin(form){
form.display.value = Math.sin(form.display.value);
}
function tan(form){
form.display.value = Math.tan(form.display.value);
}
function sqrt(form){
form.display.value = Math.sqrt(form.display.value);
}
function ln(form){
form.display.value = Math.log(form.display.value);
}
function exp(form){
form.display.value = Math.exp(form.display.value);
}
function deleteChar(input){
input.value = input.value.substring(0, input.value.length -1)
}
var val =0.0;
function percent(input){
val = input.value;
input.value = input.value +"%";
}
function changeSign(input){
if(input.value.substring(0,1)=="-")
input.value = input.value.substring(1, input.value.length)
else
input.value ="-"+ input.value
}
function compute(form){
//if (val !==0.0){
// var percent = form.display.value;
// percent = pcent.substring(percent.indexOf("%")+1);
// form.display.value = parseFloat(percent)/100* val;
//val =0.0;
//} else
form.display.value = eval(form.display.value);
}
function square(form){
form.display.value = eval(form.display.value)* eval(form.display.value)
}
function checkNum(str){
for (var i =0; i < str.length; i++){
var ch = str.charAt(i);
if (ch <"0"|| ch >"9"){
if (ch !="/" && ch !="*" && ch !="+" && ch !="-" && ch !="."
&& ch !="(" && ch!=")" && ch !="%"){
alert("invalid entry!")
return false
}
}
}
return true
}
In this part you are to develop a set of unit tests for a scientific calculator program written in JavaScript. At first run the program. Try to use it to calculate some expressions. Then try to understand how does it work. Finally:
a)Write a total of 9 tests, organized into three sets.
b) Each test set should target one functional element of the program (You cannot choose +,-,/ and *)
c)Write the code that allows the program to pass your tests.
d) Explain your approach in each test set. What was your strategy here?
e) Capture screenshots or console logs of the code before and after it passed the tests, showing the output of the unit testing library. Shorten the output to the most important part, where it lists the number of tests passed and failed.
DO NOT COPY FROM OTHER ANSWERS AND PLEASE GIVE COMPLETE ANSWERS. A LOT OF THE EXPERTS ARE GIVING ONLY 1 OR 2 TESTS. PLEASE GIVE ALL 9 AND ALL a-e. PLEASE.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

Do the measurement items or tools have content relevance?

Answered: 1 week ago