OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/logical_expression_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__logical_expression_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const _interceptors = dart_sdk._interceptors; |
| 8 const dart = dart_sdk.dart; |
| 9 const dartx = dart_sdk.dartx; |
| 10 const expect$ = expect.expect; |
| 11 const logical_expression_test = Object.create(null); |
| 12 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 13 let VoidTobool = () => (VoidTobool = dart.constFn(dart.definiteFunctionType(co
re.bool, [])))(); |
| 14 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 15 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 16 let ListTovoid = () => (ListTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [core.List])))(); |
| 17 logical_expression_test.globalCounter = 0; |
| 18 logical_expression_test.falseWithSideEffect = function() { |
| 19 function confuse() { |
| 20 return new core.DateTime.now().millisecondsSinceEpoch == 42; |
| 21 } |
| 22 dart.fn(confuse, VoidTobool()); |
| 23 let result = confuse(); |
| 24 if (dart.test(result)) { |
| 25 try { |
| 26 try { |
| 27 if (dart.test(confuse())) logical_expression_test.falseWithSideEffect(
); |
| 28 if (dart.test(confuse())) return 499; |
| 29 } catch (e) { |
| 30 throw e; |
| 31 } |
| 32 |
| 33 } catch (e) { |
| 34 throw e; |
| 35 } |
| 36 |
| 37 } |
| 38 logical_expression_test.globalCounter = dart.notNull(logical_expression_test
.globalCounter) + 1; |
| 39 return result; |
| 40 }; |
| 41 dart.fn(logical_expression_test.falseWithSideEffect, VoidTodynamic()); |
| 42 logical_expression_test.falseWithoutSideEffect = function() { |
| 43 function confuse() { |
| 44 return new core.DateTime.now().millisecondsSinceEpoch == 42; |
| 45 } |
| 46 dart.fn(confuse, VoidTobool()); |
| 47 let result = confuse(); |
| 48 if (dart.test(result)) { |
| 49 try { |
| 50 try { |
| 51 if (dart.test(confuse())) logical_expression_test.falseWithSideEffect(
); |
| 52 if (dart.test(confuse())) return 499; |
| 53 } catch (e) { |
| 54 throw e; |
| 55 } |
| 56 |
| 57 } catch (e) { |
| 58 throw e; |
| 59 } |
| 60 |
| 61 } |
| 62 return result; |
| 63 }; |
| 64 dart.fn(logical_expression_test.falseWithoutSideEffect, VoidTodynamic()); |
| 65 logical_expression_test.testLogicalOr = function() { |
| 66 logical_expression_test.globalCounter = 0; |
| 67 let cond1 = core.bool._check(logical_expression_test.falseWithSideEffect()); |
| 68 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 69 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 70 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 71 expect$.Expect.equals(1, logical_expression_test.globalCounter); |
| 72 cond1 = dart.equals(logical_expression_test.falseWithSideEffect(), 499); |
| 73 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 74 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 75 if (dart.test(cond1) || dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 76 expect$.Expect.equals(2, logical_expression_test.globalCounter); |
| 77 }; |
| 78 dart.fn(logical_expression_test.testLogicalOr, VoidTodynamic()); |
| 79 dart.defineLazy(logical_expression_test, { |
| 80 get globalList() { |
| 81 return []; |
| 82 }, |
| 83 set globalList(_) {} |
| 84 }); |
| 85 logical_expression_test.testLogicalOr2 = function() { |
| 86 logical_expression_test.globalList[dartx.clear](); |
| 87 logical_expression_test.testValueOr([]); |
| 88 logical_expression_test.testValueOr(null); |
| 89 expect$.Expect.listEquals(JSArrayOfint().of([1, 2, 3]), logical_expression_t
est.globalList); |
| 90 }; |
| 91 dart.fn(logical_expression_test.testLogicalOr2, VoidTovoid()); |
| 92 logical_expression_test.testValueOr = function(list) { |
| 93 if (list == null) logical_expression_test.globalList[dartx.add](1); |
| 94 if (list == null || dart.test(list[dartx.contains]("2"))) logical_expression
_test.globalList[dartx.add](2); |
| 95 if (list == null || dart.test(list[dartx.contains]("3"))) logical_expression
_test.globalList[dartx.add](3); |
| 96 }; |
| 97 dart.fn(logical_expression_test.testValueOr, ListTovoid()); |
| 98 logical_expression_test.testLogicalAnd = function() { |
| 99 logical_expression_test.globalCounter = 0; |
| 100 let cond1 = core.bool._check(logical_expression_test.falseWithSideEffect()); |
| 101 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 102 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 103 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 104 expect$.Expect.equals(1, logical_expression_test.globalCounter); |
| 105 cond1 = dart.equals(logical_expression_test.falseWithSideEffect(), 499); |
| 106 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 107 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 108 if (dart.test(cond1) && dart.test(logical_expression_test.falseWithoutSideEf
fect())) expect$.Expect.fail("must be false"); |
| 109 expect$.Expect.equals(2, logical_expression_test.globalCounter); |
| 110 }; |
| 111 dart.fn(logical_expression_test.testLogicalAnd, VoidTodynamic()); |
| 112 logical_expression_test.testLogicalAnd2 = function() { |
| 113 logical_expression_test.globalList[dartx.clear](); |
| 114 logical_expression_test.testValueAnd([]); |
| 115 logical_expression_test.testValueAnd(null); |
| 116 expect$.Expect.listEquals(JSArrayOfint().of([1, 2, 3]), logical_expression_t
est.globalList); |
| 117 }; |
| 118 dart.fn(logical_expression_test.testLogicalAnd2, VoidTovoid()); |
| 119 logical_expression_test.testValueAnd = function(list) { |
| 120 if (list == null) logical_expression_test.globalList[dartx.add](1); |
| 121 if (list == null && dart.test(logical_expression_test.globalList[dartx.conta
ins](1))) logical_expression_test.globalList[dartx.add](2); |
| 122 if (list == null && dart.test(logical_expression_test.globalList[dartx.conta
ins](1))) logical_expression_test.globalList[dartx.add](3); |
| 123 }; |
| 124 dart.fn(logical_expression_test.testValueAnd, ListTovoid()); |
| 125 logical_expression_test.main = function() { |
| 126 logical_expression_test.testLogicalOr(); |
| 127 logical_expression_test.testLogicalOr2(); |
| 128 logical_expression_test.testLogicalAnd(); |
| 129 logical_expression_test.testLogicalAnd2(); |
| 130 }; |
| 131 dart.fn(logical_expression_test.main, VoidTodynamic()); |
| 132 // Exports: |
| 133 exports.logical_expression_test = logical_expression_test; |
| 134 }); |
OLD | NEW |