-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CellError fields should be immutable. Fixed CYCLE address.
- Loading branch information
Showing
5 changed files
with
46 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -1,44 +1,70 @@ | ||
import {ErrorType, HyperFormula} from '../src' | ||
import {adr, detailedErrorWithOrigin} from './testUtils' | ||
import {adr, detailedError, detailedErrorWithOrigin} from './testUtils' | ||
|
||
describe('Address preservation.', () => { | ||
it('Should work in the basic case.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=NA()', '=A1'] | ||
]) | ||
expect(engine.getCellValue(adr('A1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('A1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
}) | ||
|
||
it('Should work with named expressions.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=NAMEDEXPRESSION', '=A1'] | ||
]) | ||
engine.addNamedExpression('NAMEDEXPRESSION', '=NA()') | ||
expect(engine.getCellValue(adr('A1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('A1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'NAMEDEXPRESSION')) | ||
expect(engine.getCellValue(adr('B1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'NAMEDEXPRESSION')) | ||
}) | ||
|
||
it('Should work with operators.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=NA()', '=NA()', '=A1+B1'] | ||
]) | ||
expect(engine.getCellValue(adr('C1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('C1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
}) | ||
|
||
it('Should work between sheets.', () => { | ||
const engine = HyperFormula.buildFromSheets({ | ||
sheet1: [['=NA()']], | ||
sheet2: [['=sheet1!A1']] | ||
}) | ||
expect(engine.getCellValue(adr('A1', 0))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'sheet1!A1')) | ||
expect(engine.getCellValue(adr('A1', 1))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'sheet1!A1')) | ||
expect(engine.getCellValue(adr('A1', 0))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'sheet1!A1')) | ||
expect(engine.getCellValue(adr('A1', 1))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'sheet1!A1')) | ||
}) | ||
|
||
it('Should work with function calls.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=NA()', '=DATE(1,1,A1)'] | ||
]) | ||
expect(engine.getCellValue(adr('B1'))).toEqualError(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqual(detailedErrorWithOrigin(ErrorType.NA, 'Sheet1!A1')) | ||
}) | ||
|
||
it('Should work with CYCLE.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=B1', '=A1'], | ||
['=A1', '=B1'], | ||
['=A1', '=B1'] | ||
]) | ||
expect(engine.getCellValue(adr('A1'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!B1')) | ||
expect(engine.getCellValue(adr('A2'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B2'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!B1')) | ||
expect(engine.getCellValue(adr('A3'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B3'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!B1')) | ||
}) | ||
|
||
it('Should work with CYCLE #2.', () => { | ||
const engine = HyperFormula.buildFromArray([ | ||
['=B1', '=A1'], | ||
['=A1'], | ||
['=A1'] | ||
]) | ||
expect(engine.getCellValue(adr('A1'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('B1'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!B1')) | ||
expect(engine.getCellValue(adr('A2'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
expect(engine.getCellValue(adr('A3'))).toEqual(detailedErrorWithOrigin(ErrorType.CYCLE, 'Sheet1!A1')) | ||
}) | ||
}) |