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

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

Issue 2990083002: dart2js_native tests: Migrate 'native STRING' to JS-calls - part 2/2 (Closed)
Patch Set: remove defunct comments 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 // Test that native objects cannot accidentally or maliciously be mistaken for 7 // Test that native objects cannot accidentally or maliciously be mistaken for
8 // Dart objects. 8 // Dart objects.
9 9
10 // This test currently fails because we do not recognize the need for 10 // This test currently fails because we do not recognize the need for
11 // interceptors without native *classes*. 11 // interceptors without native *classes*.
12 12
13 class Thing {} 13 class Thing {}
14 14
15 make1() native; 15 make1() native;
16 make2() native; 16 make2() native;
17 17
18 void setup() native r""" 18 void setup() {
19 function A() {} 19 JS('', r"""
20 A.prototype.$isThing = true; 20 (function(){
21 make1 = function(){return new A;}; 21 function A() {}
22 make2 = function(){return {$isThing: true}}; 22 A.prototype.$isThing = true;
23 """; 23 make1 = function(){return new A;};
24 make2 = function(){return {$isThing: true}};
25 })()""");
26 }
24 27
25 inscrutable(x) { 28 inscrutable(x) {
26 if (new DateTime.now().millisecondsSinceEpoch == 0) { 29 if (new DateTime.now().millisecondsSinceEpoch == 0) {
27 return x; 30 return x;
28 } else { 31 } else {
29 return 42; 32 return 42;
30 } 33 }
31 } 34 }
32 35
33 main() { 36 main() {
34 setup(); 37 setup();
35 38
36 var a = new Thing(); 39 var a = new Thing();
37 var b = make1(); 40 var b = make1();
38 var c = make2(); 41 var c = make2();
39 Expect.isTrue(inscrutable(a) is Thing); 42 Expect.isTrue(inscrutable(a) is Thing);
40 Expect.isFalse(inscrutable(b) is Thing); 43 Expect.isFalse(inscrutable(b) is Thing);
41 Expect.isFalse(inscrutable(c) is Thing); 44 Expect.isFalse(inscrutable(c) is Thing);
42 } 45 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_native/fake_thing_2_test.dart ('k') | tests/compiler/dart2js_native/fixup_get_tag_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698