-
Notifications
You must be signed in to change notification settings - Fork 106
/
infinity.spec.ts
93 lines (72 loc) · 2.61 KB
/
infinity.spec.ts
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
87
88
89
90
91
92
93
import { HyperFormula, DetailedCellError } from '../../src'
import '../testConfig'
import { adr } from '../testUtils'
import { CellError, ErrorType, CellType } from '../../src/Cell'
import { EmptyValue } from '../../src/Cell'
import { LogarithmPlugin } from '../../src/interpreter/plugin/LogarithmPlugin'
function createEngine(data: any[][]) {
const engine = HyperFormula.buildFromArray(data)
return {
getCellValue(cellAddress: string) {
return engine.getCellValue(adr(cellAddress))
}
}
}
describe('Quality assurance of operators', () => {
it('LOG(0) should thrown #NUM! error', () => {
const engine = createEngine([
[0],
['=LOG(A1)'],
])
expect(engine.getCellValue('A2')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('EXP(1000000000) should thrown #NUM! error', () => { //pending for #196
const engine = createEngine([
[1000000000],
['=EXP(A1)']
])
expect(engine.getCellValue('A2')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('SQRT(-2)should thrown #NUM! error', () => {
const engine = createEngine([
['=SQRT(-2)']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('1000^500 should thrown #NUM! error', () => { //pending for #196
const engine = createEngine([
['=1000^500']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('smallest number -1*10 ^308 should return -1.0000000000000006e+308', () => {
const engine = createEngine([
['=-1*10 ^308']
])
expect(engine.getCellValue('A1')).toBe(-1e+308)
})
it('too small -1*10^309 should return #NUM!', () => {
const engine = createEngine([
['=-1*10 ^309']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('too big number should return #NUM!', () => {
const engine = createEngine([
['=9.99*10 ^308']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('too big number should return #NUM!', () => {
const engine = createEngine([
['=9.99*10 ^308']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
it('too big number should return #NUM!', () => {
const engine = createEngine([
['=9.99*10 ^308']
])
expect(engine.getCellValue('A1')).toEqual(new DetailedCellError(new CellError(ErrorType.NUM), '#NUM!'))
})
})