-
-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(formula): plus,minus,multiply,divided functions return value error
- Loading branch information
Showing
5 changed files
with
198 additions
and
10 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/engine-formula/src/engine/value-object/__tests__/array-value-divided.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { ArrayValueObject, transformToValueObject } from '../array-value-object'; | ||
import { NumberValueObject } from '../primitive-object'; | ||
import { ErrorType } from '../../..'; | ||
|
||
describe('ArrayValueObject divided method test', () => { | ||
describe('Divided', () => { | ||
it('Origin nm, param 1', () => { | ||
const arrayValueObject = new ArrayValueObject({ | ||
calculateValueList: transformToValueObject([ | ||
[1, ' ', 1.23, true, false, null], | ||
[0, '100', '2.34', 'test', -3, ErrorType.VALUE], | ||
]), | ||
rowCount: 2, | ||
columnCount: 6, | ||
unitId: '', | ||
sheetId: '', | ||
row: 0, | ||
column: 0, | ||
}); | ||
|
||
const valueObject = new NumberValueObject(1); | ||
|
||
expect((arrayValueObject.divided(valueObject) as ArrayValueObject).toValue()).toStrictEqual([ | ||
[1, ErrorType.VALUE, 1.23, 1, 0, 0], | ||
[0, 100, 2.34, ErrorType.VALUE, -3, ErrorType.VALUE], | ||
]); | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/engine-formula/src/engine/value-object/__tests__/array-value-minus.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { ArrayValueObject, transformToValueObject } from '../array-value-object'; | ||
import { NumberValueObject } from '../primitive-object'; | ||
import { ErrorType } from '../../..'; | ||
|
||
describe('ArrayValueObject minus method test', () => { | ||
describe('Minus', () => { | ||
it('Origin nm, param 1', () => { | ||
const arrayValueObject = new ArrayValueObject({ | ||
calculateValueList: transformToValueObject([ | ||
[1, ' ', 1.23, true, false, null], | ||
[0, '100', '2.34', 'test', -3, ErrorType.VALUE], | ||
]), | ||
rowCount: 2, | ||
columnCount: 6, | ||
unitId: '', | ||
sheetId: '', | ||
row: 0, | ||
column: 0, | ||
}); | ||
|
||
const valueObject = new NumberValueObject(1); | ||
|
||
expect((arrayValueObject.minus(valueObject) as ArrayValueObject).toValue()).toStrictEqual([ | ||
[0, ErrorType.VALUE, 0.23, 0, -1, -1], | ||
[-1, 99, 1.34, ErrorType.VALUE, -4, ErrorType.VALUE], | ||
]); | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/engine-formula/src/engine/value-object/__tests__/array-value-multiply.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { ArrayValueObject, transformToValueObject } from '../array-value-object'; | ||
import { NumberValueObject } from '../primitive-object'; | ||
import { ErrorType } from '../../..'; | ||
|
||
describe('ArrayValueObject multiply method test', () => { | ||
describe('Multiply', () => { | ||
it('Origin nm, param 1', () => { | ||
const arrayValueObject = new ArrayValueObject({ | ||
calculateValueList: transformToValueObject([ | ||
[1, ' ', 1.23, true, false, null], | ||
[0, '100', '2.34', 'test', -3, ErrorType.VALUE], | ||
]), | ||
rowCount: 2, | ||
columnCount: 6, | ||
unitId: '', | ||
sheetId: '', | ||
row: 0, | ||
column: 0, | ||
}); | ||
|
||
const valueObject = new NumberValueObject(1); | ||
|
||
expect((arrayValueObject.multiply(valueObject) as ArrayValueObject).toValue()).toStrictEqual([ | ||
[1, ErrorType.VALUE, 1.23, 1, 0, 0], | ||
[0, 100, 2.34, ErrorType.VALUE, -3, ErrorType.VALUE], | ||
]); | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
packages/engine-formula/src/engine/value-object/__tests__/array-value-plus.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2023-present DreamNum Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { ArrayValueObject, transformToValueObject } from '../array-value-object'; | ||
import { NumberValueObject } from '../primitive-object'; | ||
import { ErrorType } from '../../..'; | ||
|
||
describe('ArrayValueObject plus method test', () => { | ||
describe('Plus', () => { | ||
it('Origin nm, param 1', () => { | ||
const arrayValueObject = new ArrayValueObject({ | ||
calculateValueList: transformToValueObject([ | ||
[1, ' ', 1.23, true, false, null], | ||
[0, '100', '2.34', 'test', -3, ErrorType.VALUE], | ||
]), | ||
rowCount: 2, | ||
columnCount: 6, | ||
unitId: '', | ||
sheetId: '', | ||
row: 0, | ||
column: 0, | ||
}); | ||
|
||
const valueObject = new NumberValueObject(1); | ||
|
||
expect((arrayValueObject.plus(valueObject) as ArrayValueObject).toValue()).toStrictEqual([ | ||
[2, ErrorType.VALUE, 2.23, 2, 1, 1], | ||
[1, 101, 3.34, ErrorType.VALUE, -2, ErrorType.VALUE], | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters