| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('total_tests'); | 5 #library('total_tests'); |
| 6 | 6 |
| 7 #import('../../../../base/base.dart'); | 7 #import('../../../../base/base.dart'); |
| 8 #import('dart:html'); | 8 #import('dart:html'); |
| 9 #import('../../../../samples/total/src/TotalLib.dart'); | 9 #import('../../../../samples/total/src/TotalLib.dart'); |
| 10 #import('../../../../testing/unittest/unittest.dart'); | 10 #import('../../../../testing/unittest/unittest.dart'); |
| 11 #import('../../../../view/view.dart'); | 11 #import('../../../../view/view.dart'); |
| 12 #source('../../../../../samples/total/src/SYLKProducer.dart'); |
| 12 | 13 |
| 13 main() { | 14 main() { |
| 14 test('DateUtils', () { | 15 test('DateUtils', () { |
| 15 _isDate('1/1'); | 16 _isDate('1/1'); |
| 16 _isDate('12/1'); | 17 _isDate('12/1'); |
| 17 _isDate('11/31'); | 18 _isDate('11/31'); |
| 18 _isDate('01/1'); | 19 _isDate('01/1'); |
| 19 _isDate('1/01'); | 20 _isDate('1/01'); |
| 20 _isDate('01/01'); | 21 _isDate('01/01'); |
| 21 _isDate('1-1'); | 22 _isDate('1-1'); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 validate("GCD(7,1)", 1.0); | 361 validate("GCD(7,1)", 1.0); |
| 361 validate("GCD(5,0)", 5.0); | 362 validate("GCD(5,0)", 5.0); |
| 362 validate("LCM(5,2)", 10.0); | 363 validate("LCM(5,2)", 10.0); |
| 363 validate("LCM(24,36)", 72.0); | 364 validate("LCM(24,36)", 72.0); |
| 364 validate("LCM(24,36,5)", 360.0); | 365 validate("LCM(24,36,5)", 360.0); |
| 365 validate("MULTINOMIAL(2, 3, 4)", 1260.0); | 366 validate("MULTINOMIAL(2, 3, 4)", 1260.0); |
| 366 validate("SERIESSUM(PI()/4,0,2,1,-1/FACT(2),1/FACT(4),-1/FACT(6))", 0.707103
); | 367 validate("SERIESSUM(PI()/4,0,2,1,-1/FACT(2),1/FACT(4),-1/FACT(6))", 0.707103
); |
| 367 }); | 368 }); |
| 368 | 369 |
| 369 test('Mortgage', () { | 370 test('Mortgage', () { |
| 371 SYLKProducer producer = new SYLKProducer(); |
| 372 String data = producer.makeExample("mortgage"); |
| 373 Spreadsheet spreadsheet = new Spreadsheet(); |
| 370 Reader reader = new SYLKReader(); | 374 Reader reader = new SYLKReader(); |
| 371 List<String> data = reader.makeExample("mortgage"); | 375 reader.loadFromString(spreadsheet, data); |
| 372 Spreadsheet spreadsheet = new Spreadsheet(); | |
| 373 reader.loadSpreadsheet(spreadsheet, data); | |
| 374 Expect.approxEquals(383.05, spreadsheet.getDoubleValue(new RowCol(99, 2)), 0
.05); | 376 Expect.approxEquals(383.05, spreadsheet.getDoubleValue(new RowCol(99, 2)), 0
.05); |
| 375 Expect.approxEquals(36977.28, spreadsheet.getDoubleValue(new RowCol(100, 2))
, 0.05); | 377 Expect.approxEquals(36977.28, spreadsheet.getDoubleValue(new RowCol(100, 2))
, 0.05); |
| 376 Expect.approxEquals(6976.86, spreadsheet.getDoubleValue(new RowCol(100, 3)),
0.05); | 378 Expect.approxEquals(6976.86, spreadsheet.getDoubleValue(new RowCol(100, 3)),
0.05); |
| 377 Expect.approxEquals(30000.42, spreadsheet.getDoubleValue(new RowCol(100, 4))
, 0.05); | 379 Expect.approxEquals(30000.42, spreadsheet.getDoubleValue(new RowCol(100, 4))
, 0.05); |
| 378 }); | 380 }); |
| 379 | 381 |
| 380 test('Vlookup', () { | 382 test('Vlookup', () { |
| 381 Spreadsheet spreadsheet = new Spreadsheet(); | 383 Spreadsheet spreadsheet = new Spreadsheet(); |
| 382 spreadsheet.setCellFromContentString(new RowCol(1, 1), "4.14"); | 384 spreadsheet.setCellFromContentString(new RowCol(1, 1), "4.14"); |
| 383 spreadsheet.setCellFromContentString(new RowCol(2, 1), "4.19"); | 385 spreadsheet.setCellFromContentString(new RowCol(2, 1), "4.19"); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 Expect.isFalse(DateUtils.isDate(date), "DateUtils.isDate(${date})"); | 444 Expect.isFalse(DateUtils.isDate(date), "DateUtils.isDate(${date})"); |
| 443 } | 445 } |
| 444 | 446 |
| 445 _assertNumeric(String s) { | 447 _assertNumeric(String s) { |
| 446 Expect.isTrue(StringUtils.isNumeric(s), 'StringUtils.isNumeric("{$s}")'); | 448 Expect.isTrue(StringUtils.isNumeric(s), 'StringUtils.isNumeric("{$s}")'); |
| 447 } | 449 } |
| 448 | 450 |
| 449 _assertNonNumeric(String s) { | 451 _assertNonNumeric(String s) { |
| 450 Expect.isFalse(StringUtils.isNumeric(s), '!StringUtils.isNumeric("${s}")'); | 452 Expect.isFalse(StringUtils.isNumeric(s), '!StringUtils.isNumeric("${s}")'); |
| 451 } | 453 } |
| OLD | NEW |