Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/compiler/dart2js_native/native_equals_frog_test.dart

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 'native_testing.dart'; 5 import 'native_testing.dart';
6 6
7 @Native("A") 7 @Native("A")
8 class A {} 8 class A {}
9 9
10 int calls = 0; 10 int calls = 0;
11 11
12 @Native("B") 12 @Native("B")
13 class B { 13 class B {
14 bool operator ==(other) { 14 bool operator ==(other) {
15 ++calls; 15 ++calls;
16 return other is B; 16 return other is B;
17 } 17 }
18 18
19 int get hashCode => 1; 19 int get hashCode => 1;
20 } 20 }
21 21
22 makeA() native; 22 makeA() native;
23 makeB() native; 23 makeB() native;
24 24
25 void setup() native """ 25 void setup() {
26 function A() {} 26 JS('', r"""
27 function B() {} 27 (function(){
28 makeA = function(){return new A;}; 28 function A() {}
29 makeB = function(){return new B;}; 29 function B() {}
30 makeA = function(){return new A()};
31 makeB = function(){return new B()};
30 32
31 self.nativeConstructor(B); 33 self.nativeConstructor(B);
32 """; 34 })()""");
35 }
33 36
34 main() { 37 main() {
35 nativeTesting(); 38 nativeTesting();
36 setup(); 39 setup();
37 var a = makeA(); 40 var a = makeA();
38 Expect.isTrue(a == a); 41 Expect.isTrue(a == a);
39 Expect.isTrue(identical(a, a)); 42 Expect.isTrue(identical(a, a));
40 43
41 Expect.isFalse(a == makeA()); 44 Expect.isFalse(a == makeA());
42 Expect.isFalse(identical(a, makeA())); 45 Expect.isFalse(identical(a, makeA()));
43 46
44 var b = makeB(); 47 var b = makeB();
45 Expect.isTrue(b == b); 48 Expect.isTrue(b == b);
46 Expect.isTrue(identical(b, b)); 49 Expect.isTrue(identical(b, b));
47 50
48 Expect.isTrue(b == makeB()); 51 Expect.isTrue(b == makeB());
49 Expect.isFalse(identical(b, makeB())); 52 Expect.isFalse(identical(b, makeB()));
50 53
51 Expect.equals(2, calls); 54 Expect.equals(2, calls);
52 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698