b76b3bbbf4
If getter lookup succeeds, but getter invocation throws an exception, the result is the thrown exception and not as previously noSuchMethod invocation. BUG=https://code.google.com/p/dart/issues/detail?id=11512 TEST=tests/language/method_invocation_test.dart R=srdjan@google.com Review URL: https://codereview.chromium.org//17675002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24457 260f80e4-7a28-3924-810f-c04153c831b5
53 lines
1010 B
Dart
53 lines
1010 B
Dart
// Copyright (c) 2011, 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Testing method invocation.
|
|
// Currently testing only NoSuchMethodError.
|
|
|
|
class A {
|
|
A() {}
|
|
int foo() {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
class B {
|
|
get f { throw 123; }
|
|
}
|
|
|
|
class MethodInvocationTest {
|
|
static void testNullReceiver() {
|
|
A a = new A();
|
|
Expect.equals(1, a.foo());
|
|
a = null;
|
|
bool exceptionCaught = false;
|
|
try {
|
|
a.foo();
|
|
} on NoSuchMethodError catch (e) {
|
|
exceptionCaught = true;
|
|
}
|
|
Expect.equals(true, exceptionCaught);
|
|
}
|
|
|
|
static testGetterMethodInvocation() {
|
|
var b = new B();
|
|
try {
|
|
b.f();
|
|
} catch (e) {
|
|
Expect.equals(123, e);
|
|
}
|
|
}
|
|
|
|
static void testMain() {
|
|
testNullReceiver();
|
|
testGetterMethodInvocation();
|
|
}
|
|
}
|
|
|
|
main() {
|
|
MethodInvocationTest.testMain();
|
|
}
|