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

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

Issue 2383273002: Revert "Add native_testing library to mock @Native classes" (Closed)
Patch Set: Created 4 years, 2 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 // Test to see if a Dart class name is confused with dispatch tag. Both class A 5 // Test to see if a Dart class name is confused with dispatch tag. Both class A
6 // and class Z have a JavaScript constuctor named "A". The dynamic native class 6 // and class Z have a JavaScript constuctor named "A". The dynamic native class
7 // dispatch hook on Object.prototype should avoid patching the Dart class A. 7 // dispatch hook on Object.prototype should avoid patching the Dart class A.
8 // This could be done by renaming the Dart constructor or by being able to check 8 // This could be done by renaming the Dart constructor or by being able to check
9 // that objects are Dart classes. 9 // that objects are Dart classes.
10 10
11 import "native_testing.dart"; 11 import "dart:_js_helper";
12 import "package:expect/expect.dart";
12 13
13 class A {} 14 class A {}
14 15
15 @Native("A") 16 @Native("A")
16 class Z { 17 class Z {
17 foo() => 100; 18 foo() => 100;
18 } 19 }
19 20
20 makeZ() native ; 21 makeZ() native ;
21 22
22 void setup() native """ 23 void setup() native """
23 function A(){} 24 function A(){}
24 makeZ = function(){return new A}; 25 makeZ = function(){return new A};
25 self.nativeConstructor(A);
26 """; 26 """;
27 27
28 main() { 28 main() {
29 nativeTesting();
30 setup(); 29 setup();
31 30
32 var a = new A(); 31 var a = new A();
33 var z = makeZ(); 32 var z = makeZ();
34 33
35 Expect.equals(100, z.foo()); 34 Expect.equals(100, z.foo());
36 35
37 Expect.throws(() => a.foo(), (ex) => ex is NoSuchMethodError); 36 Expect.throws(() => a.foo(), (ex) => ex is NoSuchMethodError);
38 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698