Skip to content

Commit 5ece8e6

Browse files
committed
chore: adds more unit tests
1 parent 623bafe commit 5ece8e6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

test/typescript-tests/testTypes.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,12 @@ Function ceil examples
17861786
math.complex(3.3, -2.7)
17871787
)
17881788

1789+
// unit input
1790+
const numCeiledUnit = math.ceil(math.unit(3.2, 'cm'), math.unit('cm'))
1791+
assert.deepStrictEqual(numCeiledUnit, math.unit(4, 'cm'))
1792+
const numCeiledUnit1Dec = math.ceil(math.unit(3.21, 'cm'), 1, math.unit('cm'))
1793+
assert.deepStrictEqual(numCeiledUnit1Dec, math.unit(3.3, 'cm'))
1794+
17891795
// array input
17901796
assert.deepStrictEqual(math.ceil([3.2, 3.8, -4.7]), [4, 4, -4])
17911797
assert.deepStrictEqual(math.ceil([3.21, 3.82, -4.71], 1), [3.3, 3.9, -4.7])
@@ -1807,12 +1813,6 @@ Function ceil examples
18071813
math.fraction(6286, 1000)
18081814
])
18091815

1810-
// unit input
1811-
const numCeiledUnit = math.ceil(math.unit(3.2, 'cm'), math.unit('cm'))
1812-
assert.deepStrictEqual(numCeiledUnit, math.unit(4, 'cm'))
1813-
const numCeiledUnit1Dec = math.ceil(math.unit(3.21, 'cm'), 1, math.unit('cm'))
1814-
assert.deepStrictEqual(numCeiledUnit1Dec, math.unit(3.3, 'cm'))
1815-
18161816
// @ts-expect-error ... verify ceil(array, array) throws an error (for now)
18171817
assert.throws(() => math.ceil([3.21, 3.82], [1, 2]), TypeError)
18181818
}
@@ -1868,6 +1868,12 @@ Function fix examples
18681868
math.complex(3.2, -2.7)
18691869
)
18701870

1871+
// unit input
1872+
const numCeiledUnit = math.fix(math.unit(3.2, 'cm'), math.unit('cm'))
1873+
assert.deepStrictEqual(numCeiledUnit, math.unit(3, 'cm'))
1874+
const numCeiledUnit1Dec = math.fix(math.unit(3.1, 'cm'), 1, math.unit('cm'))
1875+
assert.deepStrictEqual(numCeiledUnit1Dec, math.unit(3.1, 'cm'))
1876+
18711877
// array input
18721878
assert.deepStrictEqual(math.fix([3.2, 3.8, -4.7]), [3, 3, -4])
18731879
assert.deepStrictEqual(math.fix([3.21, 3.82, -4.71], 1), [3.2, 3.8, -4.7])
@@ -1944,6 +1950,12 @@ Function floor examples
19441950
math.complex(3.2, -2.8)
19451951
)
19461952

1953+
// unit input
1954+
const numCeiledUnit = math.floor(math.unit(3.2, 'cm'), math.unit('cm'))
1955+
assert.deepStrictEqual(numCeiledUnit, math.unit(3, 'cm'))
1956+
const numCeiledUnit1Dec = math.floor(math.unit(3.1, 'cm'), 1, math.unit('cm'))
1957+
assert.deepStrictEqual(numCeiledUnit1Dec, math.unit(3.1, 'cm'))
1958+
19471959
// array input
19481960
assert.deepStrictEqual(math.floor([3.2, 3.8, -4.7]), [3, 3, -5])
19491961
assert.deepStrictEqual(math.floor([3.21, 3.82, -4.71], 1), [3.2, 3.8, -4.8])

0 commit comments

Comments
 (0)