FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/test/index.test.js at master · JavaScriptIOT/mathjs · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
JavaScriptIOT
/
mathjs
Public
forked from
josdejong/mathjs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mathjs
/
test
/
index.test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (71 loc) · 2.33 KB
Breadcrumbs
mathjs
/
test
/
index.test.js
Copy path
File metadata and controls
86 lines (71 loc) · 2.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var
assert
=
require
(
'assert'
)
,
approx
=
require
(
'../tools/approx'
)
,
math
=
require
(
'../index'
)
;
describe
(
'factory'
,
function
(
)
{
it
(
'should get a default instance of mathjs'
,
function
(
)
{
assert
.
strictEqual
(
typeof
math
,
'object'
)
;
assert
.
deepEqual
(
math
.
config
(
)
,
{
matrix
:
'Matrix'
,
number
:
'number'
,
precision
:
64
,
predictable
:
false
,
epsilon
:
1e-12
,
randomSeed
:
null
}
)
;
}
)
;
it
(
'should create an instance of math.js with custom configuration'
,
function
(
)
{
var
math1
=
math
.
create
(
{
matrix
:
'Array'
,
number
:
'BigNumber'
}
)
;
assert
.
strictEqual
(
typeof
math1
,
'object'
)
;
assert
.
deepEqual
(
math1
.
config
(
)
,
{
matrix
:
'Array'
,
number
:
'BigNumber'
,
precision
:
64
,
predictable
:
false
,
epsilon
:
1e-12
,
randomSeed
:
null
}
)
;
}
)
;
it
(
'two instances of math.js should be isolated from each other'
,
function
(
)
{
var
math1
=
math
.
create
(
)
;
var
math2
=
math
.
create
(
{
matrix
:
'Array'
}
)
;
assert
.
notStrictEqual
(
math
,
math1
)
;
assert
.
notStrictEqual
(
math
,
math2
)
;
assert
.
notStrictEqual
(
math1
,
math2
)
;
assert
.
notDeepEqual
(
math1
.
config
(
)
,
math2
.
config
(
)
)
;
assert
.
notDeepEqual
(
math
.
config
(
)
,
math2
.
config
(
)
)
;
// changing config should not affect the other
math1
.
config
(
{
number
:
'BigNumber'
}
)
;
assert
.
strictEqual
(
math
.
config
(
)
.
number
,
'number'
)
;
assert
.
strictEqual
(
math1
.
config
(
)
.
number
,
'BigNumber'
)
;
assert
.
strictEqual
(
math2
.
config
(
)
.
number
,
'number'
)
;
}
)
;
it
(
'should apply configuration using the config function'
,
function
(
)
{
var
math1
=
math
.
create
(
)
;
var
config
=
math1
.
config
(
)
;
assert
.
deepEqual
(
config
,
{
matrix
:
'Matrix'
,
number
:
'number'
,
precision
:
64
,
predictable
:
false
,
epsilon
:
1e-12
,
randomSeed
:
null
}
)
;
// restore the original config
math1
.
config
(
config
)
;
}
)
;
// TODO: test whether the namespace is correct: has functions like sin, constants like pi, objects like type and error.
it
(
'should throw an error when ES5 is not supported'
,
function
(
)
{
var
create
=
Object
.
create
;
Object
.
create
=
undefined
;
// fake missing Object.create function
assert
.
throws
(
function
(
)
{
var
math1
=
math
.
create
(
)
;
}
,
/
E
S
5
n
o
t
s
u
p
p
o
r
t
e
d
/
)
;
// restore Object.create
Object
.
create
=
create
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL