Skip to content

Commit

Permalink
Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
infusion committed Sep 25, 2019
1 parent a1b0cd2 commit bb3204b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/complex.test.js
Expand Up @@ -324,6 +324,10 @@ var functionTests = [{
set: {re: 1, im: 0.5 * Math.sqrt(4 / 3)},
fn: "arg",
expect: "" + Math.PI / 6
}, {
set: "3 + 4i",
fn: "conjugate",
expect: "3 - 4i"
}, {
set: {re: 99, im: 50},
fn: "conjugate",
Expand All @@ -341,11 +345,21 @@ var functionTests = [{
fn: "div",
param: new Complex(1, 2),
expect: "3.6 + 0.8i"
}, {
set: "2 + 8i",
fn: "div",
param: "2 + 8i",
expect: "1"
}, {
set: -Infinity,
fn: "div",
param: 3,
expect: "Infinity"
}, {
set: "3+4i",
fn: "add",
param: "5 - i",
expect: "8 + 3i"
}, {
set: {re: 1, im: 2},
fn: "add",
Expand All @@ -356,6 +370,11 @@ var functionTests = [{
fn: "sub",
param: "4 + 6i",
expect: "1 + 2i"
},{
set: "3 + 4i",
fn: "sub",
param: "2 - 5i",
expect: "1 + 9i"
}, {
set: "1 + 2i",
fn: "pow",
Expand Down Expand Up @@ -390,6 +409,11 @@ var functionTests = [{
fn: "mul",
param: "4+5i",
expect: "-7 + 22i"
}, {
set: "3 + 4i",
fn: "mul",
param: "2 - 5i",
expect: "26 - 7i"
}, {
set: "i",
fn: "pow",
Expand Down Expand Up @@ -483,6 +507,10 @@ var functionTests = [{
set: {re: 1, im: 3},
fn: "inverse",
expect: "0.1 - 0.3i"
}, {
set: "3+4i",
fn: "inverse",
expect: "0.12 - 0.16i" // 3/25 - (4/25)i
}, {
set: {re: 0.5, im: -0.5},
fn: "inverse",
Expand Down

0 comments on commit bb3204b

Please sign in to comment.