From 4efea1420e41285d8aec80dc6dfbb61bd8a67bc9 Mon Sep 17 00:00:00 2001 From: "ahe@google.com" Date: Wed, 14 Nov 2012 12:29:40 +0000 Subject: [PATCH] Update dart2js_foreign suite as we now validate annotations. Review URL: https://codereview.chromium.org//11293272 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14885 260f80e4-7a28-3924-810f-c04153c831b5 --- tests/compiler/dart2js_foreign/foreign_test.dart | 2 ++ .../dart2js_foreign/native_call_arity1_test.dart | 8 +++++--- .../dart2js_foreign/native_call_arity2_test.dart | 8 +++++--- .../dart2js_foreign/native_call_arity3_test.dart | 8 +++++--- .../native_checked_arguments1_test.dart | 8 +++++--- .../native_checked_fields_test.dart | 8 +++++--- .../native_class_avoids_hidden_name_test.dart | 10 ++++++---- .../native_class_inheritance1_test.dart | 12 +++++++----- .../native_class_inheritance2_test.dart | 12 +++++++----- .../native_class_inheritance3_test.dart | 12 +++++++----- .../native_class_inheritance4_test.dart | 8 +++++--- .../native_class_is_check1_test.dart | 6 ++++-- .../native_class_is_check3_test.dart | 8 +++++--- .../native_class_with_dart_methods_test.dart | 6 ++++-- .../native_closure_identity_test.dart | 6 ++++-- .../dart2js_foreign/native_exceptions1_test.dart | 9 +++++---- .../native_field_rename_1_test.dart | 10 ++++++---- .../native_field_rename_2_test.dart | 12 +++++++----- .../native_library_same_name_used_lib2.dart | 2 +- .../native_library_same_name_used_test.dart | 3 ++- .../dart2js_foreign/native_literal_class_test.dart | 6 ++++-- .../compiler/dart2js_foreign/native_metadata.dart | 12 ++++++++++++ .../native_method_rename1_test.dart | 12 +++++++----- .../native_method_rename2_test.dart | 12 +++++++----- .../native_method_rename3_test.dart | 12 +++++++----- .../native_method_with_keyword_name_test.dart | 6 ++++-- .../native_missing_method1_test.dart | 6 ++++-- .../native_missing_method2_test.dart | 6 ++++-- .../native_named_constructors2_test.dart | 9 +++++---- .../native_named_constructors3_test.dart | 9 +++++---- .../native_no_such_method_exception2_test.dart | 8 +++++--- .../native_no_such_method_exception3_test.dart | 8 +++++--- .../native_no_such_method_exception4_test.dart | 8 +++++--- .../native_no_such_method_exception5_test.dart | 8 +++++--- .../native_no_such_method_exception_test.dart | 8 +++++--- .../dart2js_foreign/native_null_closure_test.dart | 6 ++++-- .../compiler/dart2js_foreign/native_null_test.dart | 14 ++++++++------ .../native_parameter_names_test.dart | 10 ++++++---- .../dart2js_foreign/native_property_test.dart | 14 ++++++++------ .../dart2js_foreign/native_to_string_test.dart | 6 ++++-- .../native_use_native_name_in_table_test.dart | 8 +++++--- .../dart2js_foreign/native_window1_test.dart | 4 +++- .../dart2js_foreign/native_window2_test.dart | 4 +++- .../native_wrapping_function2_test.dart | 14 ++++++++------ .../native_wrapping_function3_test.dart | 6 ++++-- .../native_wrapping_function_test.dart | 6 ++++-- 46 files changed, 238 insertions(+), 142 deletions(-) create mode 100644 tests/compiler/dart2js_foreign/native_metadata.dart diff --git a/tests/compiler/dart2js_foreign/foreign_test.dart b/tests/compiler/dart2js_foreign/foreign_test.dart index 3df5343ac08..a23e1e26c10 100644 --- a/tests/compiler/dart2js_foreign/foreign_test.dart +++ b/tests/compiler/dart2js_foreign/foreign_test.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + foreign1(var a, var b) { return JS("num", r"# + #", a, b); } diff --git a/tests/compiler/dart2js_foreign/native_call_arity1_test.dart b/tests/compiler/dart2js_foreign/native_call_arity1_test.dart index 61cd7a87432..2ae3917b057 100644 --- a/tests/compiler/dart2js_foreign/native_call_arity1_test.dart +++ b/tests/compiler/dart2js_foreign/native_call_arity1_test.dart @@ -10,12 +10,14 @@ // * Named arguments are passed in the correct position, so require preceding // arguments to be passed. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native int foo(int x); } -@native("*B") +@Native("*B") class B { @native int foo([x, y, z]); } @@ -26,7 +28,7 @@ class B { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function A() {} A.prototype.foo = function () { return arguments.length; }; diff --git a/tests/compiler/dart2js_foreign/native_call_arity2_test.dart b/tests/compiler/dart2js_foreign/native_call_arity2_test.dart index 50a71c3f2e1..b28e99eede7 100644 --- a/tests/compiler/dart2js_foreign/native_call_arity2_test.dart +++ b/tests/compiler/dart2js_foreign/native_call_arity2_test.dart @@ -5,12 +5,14 @@ // This is a similar test to NativeCallArity1FrogTest, but makes sure // that subclasses also get the right number of arguments. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native int foo([x, y]); } -@native("*B") +@Native("*B") class B extends A { @native int foo([x, y]); } @@ -18,7 +20,7 @@ class B extends A { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function inherits(child, parent) { if (child.prototype.__proto__) { child.prototype.__proto__ = parent.prototype; diff --git a/tests/compiler/dart2js_foreign/native_call_arity3_test.dart b/tests/compiler/dart2js_foreign/native_call_arity3_test.dart index 2fa0b4e73af..fb2e00b0486 100644 --- a/tests/compiler/dart2js_foreign/native_call_arity3_test.dart +++ b/tests/compiler/dart2js_foreign/native_call_arity3_test.dart @@ -6,12 +6,14 @@ // parameters set to null. These parameters should be treated as if they // do not have a default value for the native methods. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native int foo(int x); } -@native("*B") +@Native("*B") class B { @native int foo([x = null, y, z = null]); } @@ -22,7 +24,7 @@ class B { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function A() {} A.prototype.foo = function () { return arguments.length; }; diff --git a/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart b/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart index a293d0519b8..f6e169bc6a1 100644 --- a/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart +++ b/tests/compiler/dart2js_foreign/native_checked_arguments1_test.dart @@ -4,13 +4,15 @@ // Test that type checks occur on native methods. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native int foo(int x); @native int cmp(A other); } -@native("*B") +@Native("*B") class B { @native String foo(String x); @native int cmp(B other); @@ -19,7 +21,7 @@ class B { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function A() {} A.prototype.foo = function (x) { return x + 1; }; A.prototype.cmp = function (x) { return 0; }; diff --git a/tests/compiler/dart2js_foreign/native_checked_fields_test.dart b/tests/compiler/dart2js_foreign/native_checked_fields_test.dart index f1017605de0..15851b837d1 100644 --- a/tests/compiler/dart2js_foreign/native_checked_fields_test.dart +++ b/tests/compiler/dart2js_foreign/native_checked_fields_test.dart @@ -4,12 +4,14 @@ // Test that type checks occur on assignment to fields of native methods. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { int foo; } -@native("*B") +@Native("*B") class B { String foo; } @@ -17,7 +19,7 @@ class B { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function A() {} function B() {} diff --git a/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart b/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart index b9d0ff2af26..170d6e22cff 100644 --- a/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_avoids_hidden_name_test.dart @@ -4,13 +4,15 @@ // Test that hidden native class names are not used by generated code. -@native("*B") +import 'native_metadata.dart'; + +@Native("*B") class A { get name => 'A'; static A create() => makeA(); } -@native("*C") +@Native("*C") class B { get name => 'B'; static B create() => makeB(); @@ -24,7 +26,7 @@ class C { // Ordinary class with name clashing with native class. @native makeA(); @native makeB(); -@native(""" +@Native(""" // Poison hidden native names 'B' and 'C' to prove the compiler didn't place // anthing on the hidden native class. B = null; @@ -32,7 +34,7 @@ C = null; """) void setup1(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function B(){} function C(){} diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart index 6cb990365b4..0aae881a2db 100644 --- a/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_inheritance1_test.dart @@ -7,13 +7,15 @@ // superclass caches the method in the prototype, so shadowing the dispatcher // stored on Object.prototype. +import 'native_metadata.dart'; + // Version 1: It might be possible to call foo directly. -@native("*A1") +@Native("*A1") class A1 { @native foo(); } -@native("*B1") +@Native("*B1") class B1 extends A1 { @native foo(); } @@ -23,12 +25,12 @@ class B1 extends A1 { // Version 2: foo needs some kind of trampoline. -@native("*A2") +@Native("*A2") class A2 { @native foo([a=99]); } -@native("*B2") +@Native("*B2") class B2 extends A2 { @native foo([z=1000]); } @@ -36,7 +38,7 @@ class B2 extends A2 { @native makeA2(); @native makeB2(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart index dadc77c2981..77f24c32bf5 100644 --- a/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_inheritance2_test.dart @@ -7,21 +7,23 @@ // superclass caches the method in the prototype, so shadowing the dispatcher // stored on Object.prototype. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native foo([a=100]); } -@native("*B") +@Native("*B") class B extends A { } -@native("*C") +@Native("*C") class C extends B { @native foo([z=300]); } -@native("*D") +@Native("*D") class D extends C { } @@ -30,7 +32,7 @@ class D extends C { @native makeC(); @native makeD(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart index cac08151b5f..c3a085f5ddb 100644 --- a/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_inheritance3_test.dart @@ -6,11 +6,13 @@ // interferes with subsequent resolving of the method. This might happen if the // noSuchMethod is cached on Object.prototype. -@native("*A1") +import 'native_metadata.dart'; + +@Native("*A1") class A1 { } -@native("*B1") +@Native("*B1") class B1 extends A1 { } @@ -18,12 +20,12 @@ class B1 extends A1 { @native makeB1(); -@native("*A2") +@Native("*A2") class A2 { @native foo([a=99]); } -@native("*B2") +@Native("*B2") class B2 extends A2 { } @@ -32,7 +34,7 @@ class B2 extends A2 { @native makeObject(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart b/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart index 0307d8c1974..b7a8c67b682 100644 --- a/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_inheritance4_test.dart @@ -6,7 +6,9 @@ // inheritance, the superclass method must not be reached by a call on the // subclass. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { var _field; @@ -16,7 +18,7 @@ class A { int method(int z) => _field + z; } -@native("*B") +@Native("*B") class B extends A { var _field2; @@ -29,7 +31,7 @@ class B extends A { @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(r""" +@Native(r""" function inherits(child, parent) { if (child.prototype.__proto__) { child.prototype.__proto__ = parent.prototype; diff --git a/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart b/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart index c31cd8f8828..ee73eaed7ca 100644 --- a/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_is_check1_test.dart @@ -4,6 +4,8 @@ // Test for correct simple is-checks on hidden native classes. +import 'native_metadata.dart'; + interface I { I read(); write(I x); @@ -11,7 +13,7 @@ interface I { // Native implementation. -@native("*A") +@Native("*A") class A implements I { // The native class accepts only other native instances. @native A read(); @@ -20,7 +22,7 @@ class A implements I { @native makeA(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(){} A.prototype.read = function() { return this._x; }; diff --git a/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart b/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart index cae73e798bc..464e59319c1 100644 --- a/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_is_check3_test.dart @@ -4,6 +4,8 @@ // Test for correct simple is-checks on hidden native classes. +import 'native_metadata.dart'; + interface J { } @@ -14,21 +16,21 @@ interface I extends J { // Native implementation. -@native("*A") +@Native("*A") class A implements I { // The native class accepts only other native instances. @native A read(); @native write(A x); } -@native("*B") +@Native("*B") class B extends A { } @native makeA(); @native makeB(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart b/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart index 21c84fb2b70..963263ef91c 100644 --- a/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart +++ b/tests/compiler/dart2js_foreign/native_class_with_dart_methods_test.dart @@ -4,7 +4,9 @@ // Additional Dart code may be 'placed on' hidden native classes. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { var _field; @@ -17,7 +19,7 @@ class A { @native A makeA() { return new A(); } -@native(""" +@Native(""" function A() {} makeA = function(){return new A;}; """) diff --git a/tests/compiler/dart2js_foreign/native_closure_identity_test.dart b/tests/compiler/dart2js_foreign/native_closure_identity_test.dart index 11fbc3b89ef..1ba6c2ff560 100644 --- a/tests/compiler/dart2js_foreign/native_closure_identity_test.dart +++ b/tests/compiler/dart2js_foreign/native_closure_identity_test.dart @@ -2,9 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + typedef void MyFunctionType(); -@native("*A") +@Native("*A") class A { @native setClosure(MyFunctionType f); @native check(MyFunctionType f); @@ -13,7 +15,7 @@ class A { @native makeA() { return new A(); } -@native(""" +@Native(""" function A() {} A.prototype.setClosure = function(f) { this.f = f; }; A.prototype.check = function(f) { return this.f === f; }; diff --git a/tests/compiler/dart2js_foreign/native_exceptions1_test.dart b/tests/compiler/dart2js_foreign/native_exceptions1_test.dart index bfd945d05d4..40f5b9e27cd 100644 --- a/tests/compiler/dart2js_foreign/native_exceptions1_test.dart +++ b/tests/compiler/dart2js_foreign/native_exceptions1_test.dart @@ -13,9 +13,10 @@ // is no place in the Dart language to communicate (3). So we use the following // fake body technique. +import 'native_metadata.dart'; // The exception type. -@native("*E") +@Native("*E") class E { @native E._used(); // Bogus native constructor, called only from fake body. @@ -23,7 +24,7 @@ class E { } // Type with exception-throwing methods. -@native("*A") +@Native("*A") class A { @native op(int x) { // Fake body calls constructor to mark the exception class (E) as used. @@ -39,14 +40,14 @@ class B { @native makeA(); -@native(""" +@Native(""" // Ensure we are not relying on global names 'A' and 'E'. A = null; E = null; """) void setup1(); -@native(""" +@Native(""" // This code is all inside 'setup2' and so not accesible from the global scope. function E(x){ this.code = x; } diff --git a/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart b/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart index a6766fa5f4b..e8ae45ccd35 100644 --- a/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart +++ b/tests/compiler/dart2js_foreign/native_field_rename_1_test.dart @@ -6,7 +6,9 @@ // fields. However, native fields keep their name. The implication: a getter // for the field must be based on the field's name, not the field's jsname. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { int key; // jsname is 'key' int getKey() => key; @@ -18,9 +20,9 @@ class B { int getKey() => key; } -@native("*X") +@Native("*X") class X { - @native('key') int native_key_method(); + @Native('key') int native_key_method(); // This should cause B.key to be renamed, but not A.key. @natve('key') int key(); @@ -30,7 +32,7 @@ class X { @native X makeX(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(){ this.key = 111; } A.prototype.getKey = function(){return this.key;}; diff --git a/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart b/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart index 9499ff6dfde..34eaacb3a0e 100644 --- a/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart +++ b/tests/compiler/dart2js_foreign/native_field_rename_2_test.dart @@ -6,11 +6,13 @@ // fields. However, native fields keep their name. The implication: a getter // for the field must be based on the field's name, not the field's jsname. +import 'native_metadata.dart'; + interface I { int key; } -@native("*A") +@Native("*A") class A implements I { int key; // jsname is 'key' int getKey() => key; @@ -22,18 +24,18 @@ class B implements I { int getKey() => key; } -@native("*X") +@Native("*X") class X { - @native('key') int native_key_method(); + @Native('key') int native_key_method(); // This should cause B.key to be renamed, but not A.key. - @native('key') int key(); + @Native('key') int key(); } @native A makeA(); @native X makeX(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(){ this.key = 111; } A.prototype.getKey = function(){return this.key;}; diff --git a/tests/compiler/dart2js_foreign/native_library_same_name_used_lib2.dart b/tests/compiler/dart2js_foreign/native_library_same_name_used_lib2.dart index 2fbb0098d00..4f86e9fa3ad 100644 --- a/tests/compiler/dart2js_foreign/native_library_same_name_used_lib2.dart +++ b/tests/compiler/dart2js_foreign/native_library_same_name_used_lib2.dart @@ -8,7 +8,7 @@ library lib2; import 'native_library_same_name_used_lib1.dart'; // To get interface I. // Native impl has same name as interface. -@native("*I") +@Native("*I") class Impl implements I { @native Impl read(); @native write(Impl x); diff --git a/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart b/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart index f9e2bbb50f9..c3bdddaae98 100644 --- a/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart +++ b/tests/compiler/dart2js_foreign/native_library_same_name_used_test.dart @@ -6,8 +6,9 @@ library main; import 'native_library_same_name_used_lib1.dart'; +import 'native_metadata.dart'; -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function I(){} I.prototype.read = function() { return this._x; }; diff --git a/tests/compiler/dart2js_foreign/native_literal_class_test.dart b/tests/compiler/dart2js_foreign/native_literal_class_test.dart index 635859519fd..86e9fd07a1f 100644 --- a/tests/compiler/dart2js_foreign/native_literal_class_test.dart +++ b/tests/compiler/dart2js_foreign/native_literal_class_test.dart @@ -2,12 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("= {log: function() { return 42 } }") +import 'native_metadata.dart'; + +@Native("= {log: function() { return 42 } }") class A { @native void log(); } -@native(""" +@Native(""" return A; """) getA(); diff --git a/tests/compiler/dart2js_foreign/native_metadata.dart b/tests/compiler/dart2js_foreign/native_metadata.dart new file mode 100644 index 00000000000..e3a513fc76b --- /dev/null +++ b/tests/compiler/dart2js_foreign/native_metadata.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library native_metadata; + +class Native { + final String info; + const Native(this.info); +} + +const Native native = const Native(null); diff --git a/tests/compiler/dart2js_foreign/native_method_rename1_test.dart b/tests/compiler/dart2js_foreign/native_method_rename1_test.dart index a23f8b1e97d..485fb5f51b3 100644 --- a/tests/compiler/dart2js_foreign/native_method_rename1_test.dart +++ b/tests/compiler/dart2js_foreign/native_method_rename1_test.dart @@ -4,11 +4,13 @@ // Test the feature where the native string declares the native method's name. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { - @native('fooA') int foo(); - @native('barA') int bar(); - @native('bazA') int baz(); + @Native('fooA') int foo(); + @Native('barA') int bar(); + @Native('bazA') int baz(); } @native A makeA(); @@ -18,7 +20,7 @@ class B { int baz() => 900; } -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(){} A.prototype.fooA = function(){return 100;}; diff --git a/tests/compiler/dart2js_foreign/native_method_rename2_test.dart b/tests/compiler/dart2js_foreign/native_method_rename2_test.dart index 895b683e067..767f61bff3b 100644 --- a/tests/compiler/dart2js_foreign/native_method_rename2_test.dart +++ b/tests/compiler/dart2js_foreign/native_method_rename2_test.dart @@ -4,22 +4,24 @@ // Test the feature where the native string declares the native method's name. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { - @native('fooA') + @Native('fooA') int foo(); } -@native("*B") +@Native("*B") class B extends A { - @native('fooB') + @Native('fooB') int foo(); } @native makeA(); @native makeB(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_method_rename3_test.dart b/tests/compiler/dart2js_foreign/native_method_rename3_test.dart index c4ef72a38b3..bceaf9f1660 100644 --- a/tests/compiler/dart2js_foreign/native_method_rename3_test.dart +++ b/tests/compiler/dart2js_foreign/native_method_rename3_test.dart @@ -5,15 +5,17 @@ // Test the feature where the native string declares the native method's name. // #3. The name does not get -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { - @native('fooA') + @Native('fooA') int foo(); } -@native("*B") +@Native("*B") class B extends A { - @native('fooB') + @Native('fooB') int foo(); int fooA() => 333; } @@ -27,7 +29,7 @@ class Decoy { @native makeB(); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function inherits(child, parent) { if (child.prototype.__proto__) { diff --git a/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart b/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart index 2a7e491b5ea..6a1551244c5 100644 --- a/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart +++ b/tests/compiler/dart2js_foreign/native_method_with_keyword_name_test.dart @@ -4,14 +4,16 @@ // Make sure we can have a native with a name that is a JavaScript keyword. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { @native int delete(); } @native A makeA() { return new A(); } -@native(""" +@Native(""" function A() {} A.prototype.delete = function() { return 87; }; diff --git a/tests/compiler/dart2js_foreign/native_missing_method1_test.dart b/tests/compiler/dart2js_foreign/native_missing_method1_test.dart index 1739911a912..f81b9a82fe1 100644 --- a/tests/compiler/dart2js_foreign/native_missing_method1_test.dart +++ b/tests/compiler/dart2js_foreign/native_missing_method1_test.dart @@ -2,13 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { } @native makeA(); -@native(""" +@Native(""" function A() {}; A.prototype.foo = function() { return 42; } makeA = function() { return new A; } diff --git a/tests/compiler/dart2js_foreign/native_missing_method2_test.dart b/tests/compiler/dart2js_foreign/native_missing_method2_test.dart index 13feebd602f..fb99986e903 100644 --- a/tests/compiler/dart2js_foreign/native_missing_method2_test.dart +++ b/tests/compiler/dart2js_foreign/native_missing_method2_test.dart @@ -2,13 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { } @native makeA(); -@native(""" +@Native(""" function A() {}; A.prototype.foo = function() { return 42; } makeA = function() { return new A; } diff --git a/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart b/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart index e7cbaaa4a75..4c6704b1841 100644 --- a/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart +++ b/tests/compiler/dart2js_foreign/native_named_constructors2_test.dart @@ -4,26 +4,27 @@ // Hidden native class wwith named constructors and static methods. +import 'native_metadata.dart'; -@native("*A") +@Native("*A") class A { factory A(int len) => _construct(len); factory A.fromString(String s) => _construct(s.length); - @native(r'return makeA(a+b);') + @Native(r'return makeA(a+b);') factory A.nativeConstructor(int a, int b); static A _construct(v) { return makeA(v); } - @native('return this._x;') + @Native('return this._x;') foo(); } @native makeA(v); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(arg) { this._x = arg; } makeA = function(arg) { return new A(arg); } diff --git a/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart b/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart index a0319bc9bc8..18bba8e1ec3 100644 --- a/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart +++ b/tests/compiler/dart2js_foreign/native_named_constructors3_test.dart @@ -5,8 +5,9 @@ // Hidden native class with factory constructors and NO static methods. // Regression test. +import 'native_metadata.dart'; -@native("*A") +@Native("*A") class A { // No static methods in this class. @@ -15,16 +16,16 @@ class A { factory A.fromString(String s) => makeA(s.length); - @native(r'return makeA(a+b);') + @Native(r'return makeA(a+b);') factory A.nativeConstructor(int a, int b); - @native('return this._x;') + @Native('return this._x;') foo(); } @native makeA(v); -@native(""" +@Native(""" // This code is all inside 'setup' and so not accesible from the global scope. function A(arg) { this._x = arg; } makeA = function(arg) { return new A(arg); } diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart index 84740ef8a46..65f95174d3c 100644 --- a/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart +++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception2_test.dart @@ -2,11 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { } -@native("*B") +@Native("*B") class B extends A { @native foo(); } @@ -14,7 +16,7 @@ class B extends A { @native makeA(); @native makeB(); -@native(""" +@Native(""" function inherits(child, parent) { if (child.prototype.__proto__) { child.prototype.__proto__ = parent.prototype; diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart index 5779fb4a571..4aadd1b1ac5 100644 --- a/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart +++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception3_test.dart @@ -2,12 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { bar() => 42; } -@native("*B") +@Native("*B") class B { foo() => 42; } @@ -19,7 +21,7 @@ class C { @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function() { return new A; } """) diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart index b0eddc719df..b68e078b1c6 100644 --- a/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart +++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception4_test.dart @@ -2,20 +2,22 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { bar() => 42; noSuchMethod(x,y) => "native($x:$y)"; } -@native("*B") +@Native("*B") class B { baz() => 42; } @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function() { return new A; } """) diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart index 5e4b580f218..abb396156cb 100644 --- a/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart +++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception5_test.dart @@ -2,13 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { bar() => 42; noSuchMethod(x,y) => "native($x:$y)"; } -@native("*B") +@Native("*B") class B { baz() => 42; } @@ -20,7 +22,7 @@ class C { @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function() { return new A; } """) diff --git a/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart b/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart index ca530dde38c..ee9d30ef6c3 100644 --- a/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart +++ b/tests/compiler/dart2js_foreign/native_no_such_method_exception_test.dart @@ -2,19 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { bar() => 42; } -@native("*B") +@Native("*B") class B { foo() => 42; } @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function() { return new A; } """) diff --git a/tests/compiler/dart2js_foreign/native_null_closure_test.dart b/tests/compiler/dart2js_foreign/native_null_closure_test.dart index f2b3489f508..7762d1c8263 100644 --- a/tests/compiler/dart2js_foreign/native_null_closure_test.dart +++ b/tests/compiler/dart2js_foreign/native_null_closure_test.dart @@ -2,9 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + typedef void MyFunctionType(); -@native("*A") +@Native("*A") class A { @native setClosure(MyFunctionType f); @native check(MyFunctionType f); @@ -13,7 +15,7 @@ class A { @native makeA() { return new A(); } -@native(""" +@Native(""" function A() {} A.prototype.setClosure = function(f) { this.f = f; }; A.prototype.check = function(f) { return this.f === f; }; diff --git a/tests/compiler/dart2js_foreign/native_null_test.dart b/tests/compiler/dart2js_foreign/native_null_test.dart index f22046f3a2a..77db0800fd5 100644 --- a/tests/compiler/dart2js_foreign/native_null_test.dart +++ b/tests/compiler/dart2js_foreign/native_null_test.dart @@ -5,21 +5,23 @@ // Test that parameters in native methods are not mangled. This test is needed // until we change all libraries to using the JS foreign element. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { - @native("return null;") + @Native("return null;") returnNull(); - @native("return undefined;") + @Native("return undefined;") returnUndefined(); - @native("return '';") + @Native("return '';") returnEmptyString(); - @native("return 0;") + @Native("return 0;") returnZero(); } @native A makeA(); -@native(""" +@Native(""" function A() {} makeA = function(){return new A;}; """) diff --git a/tests/compiler/dart2js_foreign/native_parameter_names_test.dart b/tests/compiler/dart2js_foreign/native_parameter_names_test.dart index 7e7b32d0750..466b2267a85 100644 --- a/tests/compiler/dart2js_foreign/native_parameter_names_test.dart +++ b/tests/compiler/dart2js_foreign/native_parameter_names_test.dart @@ -5,17 +5,19 @@ // Test that parameters in native methods are not mangled. This test is needed // until we change all libraries to using the JS foreign element. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { - @native("return name;") + @Native("return name;") foo(name); - @native("return undefined;") + @Native("return undefined;") bar(undefined); } @native A makeA(); -@native(""" +@Native(""" function A() {} makeA = function(){return new A;}; """) diff --git a/tests/compiler/dart2js_foreign/native_property_test.dart b/tests/compiler/dart2js_foreign/native_property_test.dart index 34341883d75..4aa85ea2a46 100644 --- a/tests/compiler/dart2js_foreign/native_property_test.dart +++ b/tests/compiler/dart2js_foreign/native_property_test.dart @@ -4,14 +4,16 @@ // Properties on hidden native classes. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A { // Setters and getters should be similar to these methods: - @native('return this._x;') + @Native('return this._x;') int getX(); - @native('this._x = value;') + @Native('this._x = value;') void setX(int value); @native @@ -26,17 +28,17 @@ class A { @native set Y(int value); - @native('return this._z;') + @Native('return this._z;') int get Z; - @native('this._z = value;') + @Native('this._z = value;') set Z(int value); } @native A makeA() { return new A(); } -@native(""" +@Native(""" function A() {} Object.defineProperty(A.prototype, "X", { diff --git a/tests/compiler/dart2js_foreign/native_to_string_test.dart b/tests/compiler/dart2js_foreign/native_to_string_test.dart index 87059b91d56..959b2ca5f52 100644 --- a/tests/compiler/dart2js_foreign/native_to_string_test.dart +++ b/tests/compiler/dart2js_foreign/native_to_string_test.dart @@ -2,11 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -@native("*A") +import 'native_metadata.dart'; + +@Native("*A") class A {} @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function(){return new A;}; """) diff --git a/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart b/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart index 652f184db5b..b57e2679bd8 100644 --- a/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart +++ b/tests/compiler/dart2js_foreign/native_use_native_name_in_table_test.dart @@ -5,19 +5,21 @@ // Test that we put native names and not Dart names into the dynamic // dispatch table. -@native("*NativeA") +import 'native_metadata.dart'; + +@Native("*NativeA") class A { @native foo(); } -@native("*NativeB") +@Native("*NativeB") class B extends A { } @native A makeA() { return new A(); } @native B makeB() { return new B(); } -@native(""" +@Native(""" function inherits(child, parent) { if (child.prototype.__proto__) { child.prototype.__proto__ = parent.prototype; diff --git a/tests/compiler/dart2js_foreign/native_window1_test.dart b/tests/compiler/dart2js_foreign/native_window1_test.dart index 7c892378d24..ecd0b8e98df 100644 --- a/tests/compiler/dart2js_foreign/native_window1_test.dart +++ b/tests/compiler/dart2js_foreign/native_window1_test.dart @@ -2,13 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + interface Window { final int document; } // Defining this global object makes Frog eager on optimizing // call sites where the receiver is typed 'Window'. -@native("@*DOMWindow") +@Native("@*DOMWindow") class _DOMWindowJs implements Window { final int document; } diff --git a/tests/compiler/dart2js_foreign/native_window2_test.dart b/tests/compiler/dart2js_foreign/native_window2_test.dart index a9e14798e6e..414ede5fed6 100644 --- a/tests/compiler/dart2js_foreign/native_window2_test.dart +++ b/tests/compiler/dart2js_foreign/native_window2_test.dart @@ -2,13 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + interface Window { final int document; } // Defining this global object makes Frog eager on optimizing // call sites where the receiver is typed 'Window'. -@native("@*DOMWindow") +@Native("@*DOMWindow") class _DOMWindowJs implements Window { final int document; } diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart index 9690d893df5..a123a1f549e 100644 --- a/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart +++ b/tests/compiler/dart2js_foreign/native_wrapping_function2_test.dart @@ -2,28 +2,30 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + typedef void Callback0(); typedef void Callback1(arg1); typedef void Callback2(arg1, arg2); -@native("*A") +@Native("*A") class A { - @native("return closure();") + @Native("return closure();") foo0(Callback0 closure); - @native("return closure(arg1);") + @Native("return closure(arg1);") foo1(Callback1 closure, arg1); - @native("return closure(arg1, arg2);") + @Native("return closure(arg1, arg2);") foo2(Callback2 closure, arg1, arg2); - @native("return closure == (void 0) ? 42 : closure();") + @Native("return closure == (void 0) ? 42 : closure();") foo3([Callback0 closure]); } @native makeA(); -@native(""" +@Native(""" function A() {} makeA = function(){return new A;}; """) diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart index ef22da52860..e341171f415 100644 --- a/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart +++ b/tests/compiler/dart2js_foreign/native_wrapping_function3_test.dart @@ -2,11 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + typedef void Callback0(); typedef void Callback1(arg1); typedef void Callback2(arg1, arg2); -@native("*A") +@Native("*A") class A { @native foo1(Callback1 closure, [arg1 = 0]); @native foo2(Callback2 closure, [arg1 = 0, arg2 = 1]); @@ -14,7 +16,7 @@ class A { @native makeA(); -@native(""" +@Native(""" function A() {} A.prototype.foo1 = function(closure, arg1) { return closure(arg1); }; A.prototype.foo2 = function(closure, arg1, arg2) { diff --git a/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart b/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart index b34ee7ba627..5da42488a4c 100644 --- a/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart +++ b/tests/compiler/dart2js_foreign/native_wrapping_function_test.dart @@ -2,11 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'native_metadata.dart'; + typedef void Callback0(); typedef void Callback1(arg1); typedef void Callback2(arg1, arg2); -@native("*A") +@Native("*A") class A { @native foo0(Callback0 closure); @native foo1(Callback1 closure, arg1); @@ -15,7 +17,7 @@ class A { @native makeA(); -@native(""" +@Native(""" function A() {} A.prototype.foo0 = function(closure) { return closure(); }; A.prototype.foo1 = function(closure, arg1) { return closure(arg1); };