| 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 import "dart:_js_helper"; | 5 import "dart:_js_helper"; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 // Test for values of some basic types. | 8 // Test for values of some basic types. |
| 9 | 9 |
| 10 | |
| 11 @Native("A") | 10 @Native("A") |
| 12 class A { | 11 class A { |
| 13 returnNull() native; | 12 returnNull() native ; |
| 14 returnUndefined() native; | 13 returnUndefined() native ; |
| 15 returnEmptyString() native; | 14 returnEmptyString() native ; |
| 16 returnZero() native; | 15 returnZero() native ; |
| 17 } | 16 } |
| 18 | 17 |
| 19 A makeA() native; | 18 A makeA() native ; |
| 20 | 19 |
| 21 void setup() native """ | 20 void setup() native """ |
| 22 function A() {} | 21 function A() {} |
| 23 A.prototype.returnNull = function() { return null; }; | 22 A.prototype.returnNull = function() { return null; }; |
| 24 A.prototype.returnUndefined = function() { return void 0; }; | 23 A.prototype.returnUndefined = function() { return void 0; }; |
| 25 A.prototype.returnEmptyString = function() { return ""; }; | 24 A.prototype.returnEmptyString = function() { return ""; }; |
| 26 A.prototype.returnZero = function() { return 0; }; | 25 A.prototype.returnZero = function() { return 0; }; |
| 27 makeA = function(){return new A;}; | 26 makeA = function(){return new A;}; |
| 28 """; | 27 """; |
| 29 | 28 |
| 30 | |
| 31 main() { | 29 main() { |
| 32 setup(); | 30 setup(); |
| 33 A a = makeA(); | 31 A a = makeA(); |
| 34 Expect.equals(null, a.returnNull()); | 32 Expect.equals(null, a.returnNull()); |
| 35 Expect.equals(null, a.returnUndefined()); | 33 Expect.equals(null, a.returnUndefined()); |
| 36 | 34 |
| 37 Expect.equals('', a.returnEmptyString()); | 35 Expect.equals('', a.returnEmptyString()); |
| 38 Expect.isTrue(a.returnEmptyString().isEmpty); | 36 Expect.isTrue(a.returnEmptyString().isEmpty); |
| 39 Expect.isTrue(a.returnEmptyString() is String); | 37 Expect.isTrue(a.returnEmptyString() is String); |
| 40 | 38 |
| 41 Expect.isTrue(a.returnZero() is int); | 39 Expect.isTrue(a.returnZero() is int); |
| 42 Expect.equals(0, a.returnZero()); | 40 Expect.equals(0, a.returnZero()); |
| 43 } | 41 } |
| OLD | NEW |