Skip to content

Latest commit

 

History

History
135 lines (115 loc) · 1.6 KB

testcases_basics.md

File metadata and controls

135 lines (115 loc) · 1.6 KB

Refactored and Enhanced Test Cases for the Calculate function

Test Case: Basic Arithmetic (Simple Additions)

Given:

1 + 1 =
2.5 + 2.5 =

Expect:

1 + 1 = 2
2.5 + 2.5 = 5

Test Case: Variable Assignment with Various Valid Symbols

Given:

a = 5
_var = 6
alpha123 = 7

Expect:

a = 5
_var = 6
alpha123 = 7

Test Case: Arithmetic Using Variables (Including Subtraction)

Given:

a = 6
a - 2 =

Expect:

a = 6
a - 2 = 4

Test Case: Undefined Variable Referenced with Arithmetic

Given:

a = 1
a + unknown_var =

Expect:

a = 1
a + unknown_var = Error: Undefined symbol unknown_var

Test Case: Complex Arithmetic with Nested Expressions

Given:

2 * (3 + (4 - 1)) =

Expect:

2 * (3 + (4 - 1)) = 12

Test Case: Factorials and Advanced Operators

Given:

4! =
5 + 3! =

Expect:

4! = 24
5 + 3! = 11

Test Case: multiple assignments

Given:

a = 5
b = 7
c = a + b
c * 2 = 24

Expect:

a = 5
b = 7
c = a + b
c * 2 = 24

Test Case: Using Previously Declared Variables in New Expressions

Given:

x = 5
y = 10
x * y =

Expect:

x = 5
y = 10
x * y = 50

Test Case: Testing for Binary and Hexadecimal Inputs

Given:

0b1010 =
0x10 =

Expect:

0b1010 = 10
0x10 = 16

Test Case: Testing Trigonometric Values Using pi (Note: Round-off errors in trignometric functions on multiples of pi josdejong/mathjs#133)

Given:

sin(pi) =

Expect:

sin(pi) = 1.2246467991473532e-16