Index: test/codegen/language/no_such_method_native_test.dart |
diff --git a/test/codegen/language/no_such_method_native_test.dart b/test/codegen/language/no_such_method_native_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ef97c00007361932a80473c5bee5b5338e333c9 |
--- /dev/null |
+++ b/test/codegen/language/no_such_method_native_test.dart |
@@ -0,0 +1,36 @@ |
+// Copyright (c) 2016, 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. |
+// Dart test program testing that NoSuchMethod is properly called. |
+ |
+import "package:expect/expect.dart"; |
+ |
+Invocation invocation; |
+ |
+class C { |
+ noSuchMethod(Invocation i) { |
+ invocation = i; |
+ return 42; |
+ } |
+} |
+ |
+expectNSME(Object d) { |
+ try { |
+ d.noSuchMethod(invocation); |
+ } on NoSuchMethodError catch (e) { |
+ Expect.isTrue(e.toString().contains('foobar')); |
+ } |
+} |
+ |
+main() { |
+ dynamic c = new C(); |
+ Expect.equals(42, c.foobar(123)); |
+ Expect.equals(invocation.memberName, #foobar); |
+ Expect.listEquals(invocation.positionalArguments, [123]); |
+ expectNSME(null); |
+ expectNSME(777); |
+ expectNSME('hello'); |
+ // These fail because of https://github.com/dart-lang/dev_compiler/issues/592. |
+ // expectNSME([]); |
+ // expectNSME(['a', 'b', 'c']); |
+} |