Index: test/codegen/expect/corelib/duration_test.js |
diff --git a/test/codegen/expect/corelib/duration_test.js b/test/codegen/expect/corelib/duration_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8e071faf73ceb3f3281db103e1be935c0330b5b2 |
--- /dev/null |
+++ b/test/codegen/expect/corelib/duration_test.js |
@@ -0,0 +1,288 @@ |
+dart_library.library('corelib/duration_test', null, /* Imports */[ |
+ 'dart_sdk', |
+ 'expect' |
+], function load__duration_test(exports, dart_sdk, expect) { |
+ 'use strict'; |
+ const core = dart_sdk.core; |
+ const dart = dart_sdk.dart; |
+ const dartx = dart_sdk.dartx; |
+ const expect$ = expect.expect; |
+ const duration_test = Object.create(null); |
+ let VoidToDuration = () => (VoidToDuration = dart.constFn(dart.definiteFunctionType(core.Duration, [])))(); |
+ let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionType(core.bool, [dart.dynamic])))(); |
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))(); |
+ let const$; |
+ let const$0; |
+ let const$1; |
+ let const$2; |
+ let const$3; |
+ let const$4; |
+ let const$5; |
+ let const$6; |
+ let const$7; |
+ let const$8; |
+ let const$9; |
+ let const$10; |
+ let const$11; |
+ let const$12; |
+ let const$13; |
+ let const$14; |
+ let const$15; |
+ let const$16; |
+ let const$17; |
+ let const$18; |
+ let const$19; |
+ let const$20; |
+ let const$21; |
+ let const$22; |
+ let const$23; |
+ let const$24; |
+ let const$25; |
+ let const$26; |
+ let const$27; |
+ let const$28; |
+ let const$29; |
+ let const$30; |
+ let const$31; |
+ let const$32; |
+ let const$33; |
+ duration_test.main = function() { |
+ let d = null; |
+ d = new core.Duration({days: 1}); |
+ expect$.Expect.equals(86400000000, d.inMicroseconds); |
+ expect$.Expect.equals(86400000, d.inMilliseconds); |
+ expect$.Expect.equals(86400, d.inSeconds); |
+ expect$.Expect.equals(1440, d.inMinutes); |
+ expect$.Expect.equals(24, d.inHours); |
+ expect$.Expect.equals(1, d.inDays); |
+ d = const$ || (const$ = dart.const(new core.Duration({hours: 1}))); |
+ expect$.Expect.equals(3600000000, d.inMicroseconds); |
+ expect$.Expect.equals(3600000, d.inMilliseconds); |
+ expect$.Expect.equals(3600, d.inSeconds); |
+ expect$.Expect.equals(60, d.inMinutes); |
+ expect$.Expect.equals(1, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({minutes: 1}); |
+ expect$.Expect.equals(60000000, d.inMicroseconds); |
+ expect$.Expect.equals(60000, d.inMilliseconds); |
+ expect$.Expect.equals(60, d.inSeconds); |
+ expect$.Expect.equals(1, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = const$0 || (const$0 = dart.const(new core.Duration({seconds: 1}))); |
+ expect$.Expect.equals(1000000, d.inMicroseconds); |
+ expect$.Expect.equals(1000, d.inMilliseconds); |
+ expect$.Expect.equals(1, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({milliseconds: 1}); |
+ expect$.Expect.equals(1000, d.inMicroseconds); |
+ expect$.Expect.equals(1, d.inMilliseconds); |
+ expect$.Expect.equals(0, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({microseconds: 1}); |
+ expect$.Expect.equals(1, d.inMicroseconds); |
+ expect$.Expect.equals(0, d.inMilliseconds); |
+ expect$.Expect.equals(0, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = const$1 || (const$1 = dart.const(new core.Duration({milliseconds: 1, microseconds: 999}))); |
+ expect$.Expect.equals(1999, d.inMicroseconds); |
+ expect$.Expect.equals(1, d.inMilliseconds); |
+ d = const$2 || (const$2 = dart.const(new core.Duration({seconds: 1, milliseconds: 999}))); |
+ expect$.Expect.equals(1999, d.inMilliseconds); |
+ expect$.Expect.equals(1, d.inSeconds); |
+ d = new core.Duration({minutes: 1, seconds: 59}); |
+ expect$.Expect.equals(119, d.inSeconds); |
+ expect$.Expect.equals(1, d.inMinutes); |
+ d = const$3 || (const$3 = dart.const(new core.Duration({hours: 1, minutes: 59}))); |
+ expect$.Expect.equals(119, d.inMinutes); |
+ expect$.Expect.equals(1, d.inHours); |
+ d = new core.Duration({days: 1, hours: 23}); |
+ expect$.Expect.equals(47, d.inHours); |
+ expect$.Expect.equals(1, d.inDays); |
+ d = const$4 || (const$4 = dart.const(new core.Duration({days: 0, hours: 23, minutes: 59, seconds: 59, milliseconds: 999, microseconds: 999}))); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({days: -1}); |
+ expect$.Expect.equals(-86400000000, d.inMicroseconds); |
+ expect$.Expect.equals(-86400000, d.inMilliseconds); |
+ expect$.Expect.equals(-86400, d.inSeconds); |
+ expect$.Expect.equals(-1440, d.inMinutes); |
+ expect$.Expect.equals(-24, d.inHours); |
+ expect$.Expect.equals(-1, d.inDays); |
+ d = const$5 || (const$5 = dart.const(new core.Duration({hours: -1}))); |
+ expect$.Expect.equals(-3600000000, d.inMicroseconds); |
+ expect$.Expect.equals(-3600000, d.inMilliseconds); |
+ expect$.Expect.equals(-3600, d.inSeconds); |
+ expect$.Expect.equals(-60, d.inMinutes); |
+ expect$.Expect.equals(-1, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({minutes: -1}); |
+ expect$.Expect.equals(-60000000, d.inMicroseconds); |
+ expect$.Expect.equals(-60000, d.inMilliseconds); |
+ expect$.Expect.equals(-60, d.inSeconds); |
+ expect$.Expect.equals(-1, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = const$6 || (const$6 = dart.const(new core.Duration({seconds: -1}))); |
+ expect$.Expect.equals(-1000000, d.inMicroseconds); |
+ expect$.Expect.equals(-1000, d.inMilliseconds); |
+ expect$.Expect.equals(-1, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({milliseconds: -1}); |
+ expect$.Expect.equals(-1000, d.inMicroseconds); |
+ expect$.Expect.equals(-1, d.inMilliseconds); |
+ expect$.Expect.equals(0, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = new core.Duration({microseconds: -1}); |
+ expect$.Expect.equals(-1, d.inMicroseconds); |
+ expect$.Expect.equals(0, d.inMilliseconds); |
+ expect$.Expect.equals(0, d.inSeconds); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inDays); |
+ d = const$7 || (const$7 = dart.const(new core.Duration({days: 1, hours: -24}))); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = new core.Duration({hours: 1, minutes: -60}); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = const$8 || (const$8 = dart.const(new core.Duration({minutes: 1, seconds: -60}))); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = new core.Duration({seconds: 1, milliseconds: -1000}); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = new core.Duration({milliseconds: 1, microseconds: -1000}); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = const$9 || (const$9 = dart.const(new core.Duration({hours: 25}))); |
+ expect$.Expect.equals(1, d.inDays); |
+ expect$.Expect.equals(25, d.inHours); |
+ expect$.Expect.equals(1500, d.inMinutes); |
+ expect$.Expect.equals(90000, d.inSeconds); |
+ expect$.Expect.equals(90000000, d.inMilliseconds); |
+ expect$.Expect.equals(90000000000, d.inMicroseconds); |
+ d = new core.Duration({minutes: 61}); |
+ expect$.Expect.equals(0, d.inDays); |
+ expect$.Expect.equals(1, d.inHours); |
+ expect$.Expect.equals(61, d.inMinutes); |
+ expect$.Expect.equals(3660, d.inSeconds); |
+ expect$.Expect.equals(3660000, d.inMilliseconds); |
+ expect$.Expect.equals(3660000000, d.inMicroseconds); |
+ d = const$10 || (const$10 = dart.const(new core.Duration({seconds: 61}))); |
+ expect$.Expect.equals(0, d.inDays); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(1, d.inMinutes); |
+ expect$.Expect.equals(61, d.inSeconds); |
+ expect$.Expect.equals(61000, d.inMilliseconds); |
+ expect$.Expect.equals(61000000, d.inMicroseconds); |
+ d = new core.Duration({milliseconds: 1001}); |
+ expect$.Expect.equals(0, d.inDays); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(1, d.inSeconds); |
+ expect$.Expect.equals(1001, d.inMilliseconds); |
+ expect$.Expect.equals(1001000, d.inMicroseconds); |
+ d = new core.Duration({microseconds: 1001}); |
+ expect$.Expect.equals(0, d.inDays); |
+ expect$.Expect.equals(0, d.inHours); |
+ expect$.Expect.equals(0, d.inMinutes); |
+ expect$.Expect.equals(0, d.inSeconds); |
+ expect$.Expect.equals(1, d.inMilliseconds); |
+ expect$.Expect.equals(1001, d.inMicroseconds); |
+ let d1 = const$11 || (const$11 = dart.const(new core.Duration({milliseconds: 1000}))); |
+ let d2 = const$12 || (const$12 = dart.const(new core.Duration({seconds: 1}))); |
+ expect$.Expect.identical(d1, d2); |
+ d1 = const$13 || (const$13 = dart.const(new core.Duration({microseconds: 1000}))); |
+ d2 = const$14 || (const$14 = dart.const(new core.Duration({milliseconds: 1}))); |
+ expect$.Expect.identical(d1, d2); |
+ d1 = new core.Duration({hours: 1}); |
+ d2 = new core.Duration({hours: -1}); |
+ d = d1['+'](d2); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = d1['-'](d2); |
+ expect$.Expect.equals(3600000000 * 2, d.inMicroseconds); |
+ d2 = new core.Duration({hours: 1}); |
+ d = d1['+'](d2); |
+ expect$.Expect.equals(3600000000 * 2, d.inMicroseconds); |
+ d = d1['-'](d2); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = d1['*'](2); |
+ expect$.Expect.equals(3600000000 * 2, d.inMicroseconds); |
+ d = d1['*'](-1); |
+ expect$.Expect.equals(-3600000000, d.inMicroseconds); |
+ d = d1['*'](0); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = d1['~/'](2); |
+ expect$.Expect.equals(1800000000, d.inMicroseconds); |
+ d = d1['~/'](3600000001); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = d1['~/'](-3600000001); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ d = d1['~/'](3599999999); |
+ expect$.Expect.equals(1, d.inMicroseconds); |
+ d = d1['~/'](-3599999999); |
+ expect$.Expect.equals(-1, d.inMicroseconds); |
+ d = d1['~/'](-1); |
+ expect$.Expect.equals(-3600000000, d.inMicroseconds); |
+ d = d1['*'](0); |
+ expect$.Expect.equals(0, d.inMicroseconds); |
+ expect$.Expect.throws(dart.fn(() => d1['~/'](0), VoidToDuration()), dart.fn(e => core.IntegerDivisionByZeroException.is(e), dynamicTobool())); |
+ d = new core.Duration({microseconds: 0}); |
+ expect$.Expect.isTrue(d['<'](new core.Duration({microseconds: 1}))); |
+ expect$.Expect.isTrue(d['<='](new core.Duration({microseconds: 1}))); |
+ expect$.Expect.isTrue(d['<='](d)); |
+ expect$.Expect.isTrue(d['>'](new core.Duration({microseconds: -1}))); |
+ expect$.Expect.isTrue(d['>='](new core.Duration({microseconds: -1}))); |
+ expect$.Expect.isTrue(d['>='](d)); |
+ d = const$15 || (const$15 = dart.const(new core.Duration({days: 1, hours: 3, minutes: 17, seconds: 42, milliseconds: 823, microseconds: 127}))); |
+ expect$.Expect.equals("27:17:42.823127", dart.toString(d)); |
+ d = const$16 || (const$16 = dart.const(new core.Duration({hours: 1999, minutes: 17, seconds: 42}))); |
+ expect$.Expect.equals("1999:17:42.000000", dart.toString(d)); |
+ d = const$17 || (const$17 = dart.const(new core.Duration({days: -1, hours: -3, minutes: -17, seconds: -42, milliseconds: -823, microseconds: -127}))); |
+ expect$.Expect.equals("-27:17:42.823127", dart.toString(d)); |
+ d = const$18 || (const$18 = dart.const(new core.Duration({hours: -1999, minutes: -17, seconds: -42}))); |
+ expect$.Expect.equals("-1999:17:42.000000", dart.toString(d)); |
+ d = const$19 || (const$19 = dart.const(new core.Duration({microseconds: 1}))); |
+ expect$.Expect.equals("0:00:00.000001", dart.toString(d)); |
+ d = const$20 || (const$20 = dart.const(new core.Duration({microseconds: 9}))); |
+ expect$.Expect.equals("0:00:00.000009", dart.toString(d)); |
+ d = const$21 || (const$21 = dart.const(new core.Duration({microseconds: 10}))); |
+ expect$.Expect.equals("0:00:00.000010", dart.toString(d)); |
+ d = const$22 || (const$22 = dart.const(new core.Duration({microseconds: 99}))); |
+ expect$.Expect.equals("0:00:00.000099", dart.toString(d)); |
+ d = const$23 || (const$23 = dart.const(new core.Duration({microseconds: 100}))); |
+ expect$.Expect.equals("0:00:00.000100", dart.toString(d)); |
+ d = const$24 || (const$24 = dart.const(new core.Duration({microseconds: 999}))); |
+ expect$.Expect.equals("0:00:00.000999", dart.toString(d)); |
+ d = const$25 || (const$25 = dart.const(new core.Duration({microseconds: 1000}))); |
+ expect$.Expect.equals("0:00:00.001000", dart.toString(d)); |
+ d = const$26 || (const$26 = dart.const(new core.Duration({microseconds: 9999}))); |
+ expect$.Expect.equals("0:00:00.009999", dart.toString(d)); |
+ d = const$27 || (const$27 = dart.const(new core.Duration({microseconds: 10000}))); |
+ expect$.Expect.equals("0:00:00.010000", dart.toString(d)); |
+ d = const$28 || (const$28 = dart.const(new core.Duration({microseconds: 99999}))); |
+ expect$.Expect.equals("0:00:00.099999", dart.toString(d)); |
+ d = const$29 || (const$29 = dart.const(new core.Duration({microseconds: 100000}))); |
+ expect$.Expect.equals("0:00:00.100000", dart.toString(d)); |
+ d = const$30 || (const$30 = dart.const(new core.Duration({microseconds: 999999}))); |
+ expect$.Expect.equals("0:00:00.999999", dart.toString(d)); |
+ d = const$31 || (const$31 = dart.const(new core.Duration({microseconds: 1000000}))); |
+ expect$.Expect.equals("0:00:01.000000", dart.toString(d)); |
+ d1 = const$32 || (const$32 = dart.const(new core.Duration({hours: 1}))); |
+ d2 = const$33 || (const$33 = dart.const(new core.Duration({hours: -1}))); |
+ expect$.Expect.isFalse(d1.isNegative); |
+ expect$.Expect.isTrue(d2.isNegative); |
+ expect$.Expect.equals(d1, d1.abs()); |
+ expect$.Expect.equals(d1, d2.abs()); |
+ expect$.Expect.equals(d2, d1['unary-']()); |
+ expect$.Expect.equals(d1, d2['unary-']()); |
+ }; |
+ dart.fn(duration_test.main, VoidTodynamic()); |
+ // Exports: |
+ exports.duration_test = duration_test; |
+}); |