FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mathjs/test/unit-tests/type/string.test.js at develop · samxcode/mathjs · GitHub
samxcode
/
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
/
unit-tests
/
type
/
string.test.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (46 loc) · 1.94 KB
Breadcrumbs
mathjs
/
test
/
unit-tests
/
type
/
string.test.js
Copy path
File metadata and controls
57 lines (46 loc) · 1.94 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
import
assert
from
'assert'
import
math
from
'../../../src/bundleAny'
const
string
=
math
.
string
describe
(
'string'
,
function
(
)
{
it
(
'should be \'\' if called with no argument'
,
function
(
)
{
assert
.
strictEqual
(
string
(
)
,
''
)
}
)
it
(
'should convert a boolean to a string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
true
)
,
'true'
)
assert
.
strictEqual
(
string
(
false
)
,
'false'
)
}
)
it
(
'should convert null to a string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
null
)
,
'null'
)
}
)
it
(
'should be the identity if called with a string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
'hello'
)
,
'hello'
)
assert
.
strictEqual
(
string
(
''
)
,
''
)
assert
.
strictEqual
(
string
(
' '
)
,
' '
)
}
)
it
(
'should convert the elements of an array to strings'
,
function
(
)
{
assert
.
deepStrictEqual
(
string
(
[
[
2
,
true
]
,
[
'hi'
,
null
]
]
)
,
[
[
'2'
,
'true'
]
,
[
'hi'
,
'null'
]
]
)
}
)
it
(
'should convert the elements of a matrix to strings'
,
function
(
)
{
assert
.
deepStrictEqual
(
string
(
math
.
matrix
(
[
[
2
,
true
]
,
[
'hi'
,
null
]
]
)
)
,
math
.
matrix
(
[
[
'2'
,
'true'
]
,
[
'hi'
,
'null'
]
]
)
)
}
)
it
(
'should convert a number to string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
1
/
8
)
,
'0.125'
)
assert
.
strictEqual
(
string
(
2.1e-3
)
,
'0.0021'
)
assert
.
strictEqual
(
string
(
123456789
)
,
'1.23456789e+8'
)
assert
.
strictEqual
(
string
(
2000000
)
,
'2e+6'
)
}
)
it
(
'should convert a bignumber to string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
math
.
bignumber
(
'2.3e+500'
)
)
,
'2.3e+500'
)
}
)
it
(
'should convert a complex number to string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
math
.
complex
(
2
,
3
)
)
,
'2 + 3i'
)
}
)
it
(
'should convert a unit to string'
,
function
(
)
{
assert
.
strictEqual
(
string
(
math
.
unit
(
'5cm'
)
)
,
'5 cm'
)
}
)
it
(
'should throw an error if called with wrong number of arguments'
,
function
(
)
{
assert
.
throws
(
function
(
)
{
string
(
1
,
2
)
}
,
/
T
y
p
e
E
r
r
o
r
:
T
o
o
m
a
n
y
a
r
g
u
m
e
n
t
s
/
)
assert
.
throws
(
function
(
)
{
string
(
1
,
2
,
3
)
}
,
/
T
y
p
e
E
r
r
o
r
:
T
o
o
m
a
n
y
a
r
g
u
m
e
n
t
s
/
)
}
)
}
)
Back
|
FazBrowse Home
|
New Git URL