| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 var assert = chai.assert; | 5 var assert = chai.assert; |
| 6 | 6 |
| 7 suite('generic', () => { | 7 suite('generic', () => { |
| 8 "use strict"; | 8 "use strict"; |
| 9 | 9 |
| 10 let generic = dart.generic; | 10 let generic = dart.generic; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 suite('instanceOf', () => { | 78 suite('instanceOf', () => { |
| 79 "use strict"; | 79 "use strict"; |
| 80 | 80 |
| 81 let expect = assert.equal; | 81 let expect = assert.equal; |
| 82 let isGroundType = dart.isGroundType; | 82 let isGroundType = dart.isGroundType; |
| 83 let generic = dart.generic; | 83 let generic = dart.generic; |
| 84 let intIsNonNullable = false; | 84 let intIsNonNullable = false; |
| 85 let cast = dart.as; | 85 let cast = dart.as; |
| 86 let instanceOf = dart.is; | 86 let instanceOf = dart.is; |
| 87 let runtimeType = dart.realRuntimeType; | 87 let runtimeType = dart.realRuntimeType; |
| 88 let setType = dart.setType; | 88 let setRuntimeType = dart.setRuntimeType; |
| 89 let functionType = dart.functionType; | 89 let functionType = dart.functionType; |
| 90 let typedef = dart.typedef; | 90 let typedef = dart.typedef; |
| 91 | 91 |
| 92 let Object = core.Object; | 92 let Object = core.Object; |
| 93 let String = core.String; | 93 let String = core.String; |
| 94 let dynamic = dart.dynamic; | 94 let dynamic = dart.dynamic; |
| 95 let List = core.List; | 95 let List = core.List; |
| 96 let Map = core.Map; | 96 let Map = core.Map; |
| 97 let Map$ = core.Map$; | 97 let Map$ = core.Map$; |
| 98 let int = core.int; | 98 let int = core.int; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 | 111 |
| 112 let Func2 = typedef('Func2', () => functionType(dynamic, [dynamic, dynamic])); | 112 let Func2 = typedef('Func2', () => functionType(dynamic, [dynamic, dynamic])); |
| 113 let Foo = typedef('Foo', () => functionType(B, [B, String])); | 113 let Foo = typedef('Foo', () => functionType(B, [B, String])); |
| 114 | 114 |
| 115 let FuncG$ = generic((T, U) => typedef('FuncG', () => functionType(T, [T, U]))
) | 115 let FuncG$ = generic((T, U) => typedef('FuncG', () => functionType(T, [T, U]))
) |
| 116 let FuncG = FuncG$(); | 116 let FuncG = FuncG$(); |
| 117 | 117 |
| 118 // TODO(vsm): Revisit when we encode types on functions properly. | 118 // TODO(vsm): Revisit when we encode types on functions properly. |
| 119 // A bar1(C c, String s) => null; | 119 // A bar1(C c, String s) => null; |
| 120 function bar1(c, s) { return null; } | 120 function bar1(c, s) { return null; } |
| 121 setType(bar1, functionType(A, [C, String])); | 121 setRuntimeType(bar1, functionType(A, [C, String])); |
| 122 | 122 |
| 123 // bar2(B b, String s) => null; | 123 // bar2(B b, String s) => null; |
| 124 function bar2(b, s) { return null; } | 124 function bar2(b, s) { return null; } |
| 125 setType(bar2, functionType(dynamic, [B, String])); | 125 setRuntimeType(bar2, functionType(dynamic, [B, String])); |
| 126 | 126 |
| 127 // B bar3(B b, Object o) => null; | 127 // B bar3(B b, Object o) => null; |
| 128 function bar3(b, o) { return null; } | 128 function bar3(b, o) { return null; } |
| 129 setType(bar3, functionType(B, [B, Object])); | 129 setRuntimeType(bar3, functionType(B, [B, Object])); |
| 130 | 130 |
| 131 // B bar4(B b, o) => null; | 131 // B bar4(B b, o) => null; |
| 132 function bar4(b, o) { return null; } | 132 function bar4(b, o) { return null; } |
| 133 setType(bar4, functionType(B, [B, dynamic])); | 133 setRuntimeType(bar4, functionType(B, [B, dynamic])); |
| 134 | 134 |
| 135 // C bar5(A a, Object o) => null; | 135 // C bar5(A a, Object o) => null; |
| 136 function bar5(a, o) { return null; } | 136 function bar5(a, o) { return null; } |
| 137 setType(bar5, functionType(C, [A, Object])); | 137 setRuntimeType(bar5, functionType(C, [A, Object])); |
| 138 | 138 |
| 139 // B bar6(B b, String s, String o) => null; | 139 // B bar6(B b, String s, String o) => null; |
| 140 function bar6(b, s, o) { return null; } | 140 function bar6(b, s, o) { return null; } |
| 141 setType(bar6, functionType(B, [B, String, String])); | 141 setRuntimeType(bar6, functionType(B, [B, String, String])); |
| 142 | 142 |
| 143 // B bar7(B b, String s, [Object o]) => null; | 143 // B bar7(B b, String s, [Object o]) => null; |
| 144 function bar7(b, s, o) { return null; } | 144 function bar7(b, s, o) { return null; } |
| 145 setType(bar7, functionType(B, [B, String], [Object])); | 145 setRuntimeType(bar7, functionType(B, [B, String], [Object])); |
| 146 | 146 |
| 147 // B bar8(B b, String s, {Object p}) => null; | 147 // B bar8(B b, String s, {Object p}) => null; |
| 148 function bar8(b, s, o) { return null; } | 148 function bar8(b, s, o) { return null; } |
| 149 setType(bar8, functionType(B, [B, String], {p: Object})); | 149 setRuntimeType(bar8, functionType(B, [B, String], {p: Object})); |
| 150 | 150 |
| 151 function checkType(x, type, expectedTrue) { | 151 function checkType(x, type, expectedTrue) { |
| 152 if (expectedTrue === undefined) expectedTrue = true; | 152 if (expectedTrue === undefined) expectedTrue = true; |
| 153 expect(instanceOf(x, type), expectedTrue); | 153 expect(instanceOf(x, type), expectedTrue); |
| 154 } | 154 } |
| 155 | 155 |
| 156 test('int', () => { | 156 test('int', () => { |
| 157 expect(isGroundType(int), true); | 157 expect(isGroundType(int), true); |
| 158 expect(isGroundType(runtimeType(5)), true); | 158 expect(isGroundType(runtimeType(5)), true); |
| 159 | 159 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 let n = 42; | 384 let n = 42; |
| 385 let intHash = dart.hashCode(n); | 385 let intHash = dart.hashCode(n); |
| 386 checkType(intHash, core.int); | 386 checkType(intHash, core.int); |
| 387 | 387 |
| 388 let intString = dart.toString(n); | 388 let intString = dart.toString(n); |
| 389 assert.equal(intString, '42'); | 389 assert.equal(intString, '42'); |
| 390 let intType = dart.runtimeType(n); | 390 let intType = dart.runtimeType(n); |
| 391 assert.equal(intType, core.int); | 391 assert.equal(intType, core.int); |
| 392 }); | 392 }); |
| 393 }); | 393 }); |
| OLD | NEW |