OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/equality_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__equality_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const equality_test = Object.create(null); |
| 11 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 let VoidTobool = () => (VoidTobool = dart.constFn(dart.definiteFunctionType(co
re.bool, [])))(); |
| 14 const _result = Symbol('_result'); |
| 15 equality_test.A = class A extends core.Object { |
| 16 new(result) { |
| 17 this[_result] = result; |
| 18 } |
| 19 ['=='](x) { |
| 20 return this[_result]; |
| 21 } |
| 22 }; |
| 23 dart.setSignature(equality_test.A, { |
| 24 constructors: () => ({new: dart.definiteFunctionType(equality_test.A, [core.
bool])}) |
| 25 }); |
| 26 equality_test.opaque = function(x) { |
| 27 return [x, 1, 'y'][dartx.get](0); |
| 28 }; |
| 29 dart.fn(equality_test.opaque, dynamicTodynamic()); |
| 30 equality_test.Death = class Death extends core.Object { |
| 31 ['=='](x) { |
| 32 dart.throw('Dead!'); |
| 33 } |
| 34 }; |
| 35 equality_test.death = function() { |
| 36 return equality_test.opaque(new equality_test.Death()); |
| 37 }; |
| 38 dart.fn(equality_test.death, VoidTodynamic()); |
| 39 equality_test.nullFn = function() { |
| 40 return equality_test.opaque(null); |
| 41 }; |
| 42 dart.fn(equality_test.nullFn, VoidTodynamic()); |
| 43 equality_test.tests = function() { |
| 44 let alwaysTrue = new equality_test.A(true); |
| 45 let alwaysFalse = new equality_test.A(false); |
| 46 expect$.Expect.isFalse(dart.equals(alwaysFalse, alwaysFalse)); |
| 47 expect$.Expect.isTrue(!dart.equals(alwaysFalse, alwaysFalse)); |
| 48 expect$.Expect.isTrue(dart.equals(alwaysTrue, alwaysTrue)); |
| 49 expect$.Expect.isTrue(dart.equals(alwaysTrue, 5)); |
| 50 expect$.Expect.isFalse(alwaysTrue == null); |
| 51 expect$.Expect.isFalse(null == alwaysTrue); |
| 52 expect$.Expect.isTrue(alwaysTrue != null); |
| 53 expect$.Expect.isTrue(null != alwaysTrue); |
| 54 expect$.Expect.isTrue(null == null); |
| 55 expect$.Expect.isFalse(null != null); |
| 56 expect$.Expect.throws(dart.fn(() => dart.equals(equality_test.death(), 5), V
oidTobool())); |
| 57 expect$.Expect.isFalse(dart.equals(equality_test.death(), equality_test.null
Fn())); |
| 58 expect$.Expect.isFalse(dart.equals(equality_test.nullFn(), equality_test.dea
th())); |
| 59 expect$.Expect.isTrue(dart.equals(equality_test.nullFn(), equality_test.null
Fn())); |
| 60 expect$.Expect.isTrue(!dart.equals(equality_test.death(), equality_test.null
Fn())); |
| 61 expect$.Expect.isTrue(!dart.equals(equality_test.nullFn(), equality_test.dea
th())); |
| 62 expect$.Expect.isFalse(!dart.equals(equality_test.nullFn(), equality_test.nu
llFn())); |
| 63 if (dart.equals(equality_test.death(), equality_test.nullFn())) { |
| 64 dart.throw("failed"); |
| 65 } |
| 66 if (!dart.equals(equality_test.death(), equality_test.nullFn())) { |
| 67 } else { |
| 68 dart.throw("failed"); |
| 69 } |
| 70 }; |
| 71 dart.fn(equality_test.tests, VoidTodynamic()); |
| 72 equality_test.boolEqualityPositiveA = function(a) { |
| 73 return dart.equals(a, true); |
| 74 }; |
| 75 dart.fn(equality_test.boolEqualityPositiveA, dynamicTodynamic()); |
| 76 equality_test.boolEqualityNegativeA = function(a) { |
| 77 return !dart.equals(a, true); |
| 78 }; |
| 79 dart.fn(equality_test.boolEqualityNegativeA, dynamicTodynamic()); |
| 80 equality_test.boolEqualityPositiveB = function(a) { |
| 81 return dart.equals(true, a); |
| 82 }; |
| 83 dart.fn(equality_test.boolEqualityPositiveB, dynamicTodynamic()); |
| 84 equality_test.boolEqualityNegativeB = function(a) { |
| 85 return !dart.equals(true, a); |
| 86 }; |
| 87 dart.fn(equality_test.boolEqualityNegativeB, dynamicTodynamic()); |
| 88 equality_test.main = function() { |
| 89 for (let i = 0; i < 20; i++) { |
| 90 equality_test.tests(); |
| 91 expect$.Expect.isTrue(equality_test.boolEqualityPositiveA(true)); |
| 92 expect$.Expect.isFalse(equality_test.boolEqualityPositiveA(false)); |
| 93 expect$.Expect.isFalse(equality_test.boolEqualityNegativeA(true)); |
| 94 expect$.Expect.isTrue(equality_test.boolEqualityNegativeA(false)); |
| 95 expect$.Expect.isTrue(equality_test.boolEqualityPositiveB(true)); |
| 96 expect$.Expect.isFalse(equality_test.boolEqualityPositiveB(false)); |
| 97 expect$.Expect.isFalse(equality_test.boolEqualityNegativeB(true)); |
| 98 expect$.Expect.isTrue(equality_test.boolEqualityNegativeB(false)); |
| 99 } |
| 100 expect$.Expect.isFalse(equality_test.boolEqualityPositiveA(1)); |
| 101 expect$.Expect.isTrue(equality_test.boolEqualityNegativeA("hi")); |
| 102 expect$.Expect.isFalse(equality_test.boolEqualityPositiveB(2.0)); |
| 103 expect$.Expect.isTrue(equality_test.boolEqualityNegativeB([])); |
| 104 }; |
| 105 dart.fn(equality_test.main, VoidTodynamic()); |
| 106 // Exports: |
| 107 exports.equality_test = equality_test; |
| 108 }); |
OLD | NEW |