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

Side by Side Diff: tests/language/method_invocation_test.dart

Issue 17675002: Correctly deal with method invocation of a getter. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Testing method invocation. 7 // Testing method invocation.
8 // Currently testing only NoSuchMethodError. 8 // Currently testing only NoSuchMethodError.
9 9
10 class A { 10 class A {
11 A() {} 11 A() {}
12 int foo() { 12 int foo() {
13 return 1; 13 return 1;
14 } 14 }
15 } 15 }
16 16
17 class B {
18 get f { throw 123; }
19 }
20
17 class MethodInvocationTest { 21 class MethodInvocationTest {
18 static void testNullReceiver() { 22 static void testNullReceiver() {
19 A a = new A(); 23 A a = new A();
20 Expect.equals(1, a.foo()); 24 Expect.equals(1, a.foo());
21 a = null; 25 a = null;
22 bool exceptionCaught = false; 26 bool exceptionCaught = false;
23 try { 27 try {
24 a.foo(); 28 a.foo();
25 } on NoSuchMethodError catch (e) { 29 } on NoSuchMethodError catch (e) {
26 exceptionCaught = true; 30 exceptionCaught = true;
27 } 31 }
28 Expect.equals(true, exceptionCaught); 32 Expect.equals(true, exceptionCaught);
29 } 33 }
30 34
35 static testGetterMethodInvocation() {
36 var b = new B();
37 try {
38 b.f();
39 } catch (e) {
40 Expect.equals(123, e);
41 }
42 }
43
31 static void testMain() { 44 static void testMain() {
32 testNullReceiver(); 45 testNullReceiver();
46 testGetterMethodInvocation();
33 } 47 }
34 } 48 }
35 49
36 main() { 50 main() {
37 MethodInvocationTest.testMain(); 51 MethodInvocationTest.testMain();
38 } 52 }
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698