01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.jjs.test;
17:
18: import com.google.gwt.junit.client.GWTTestCase;
19:
20: /**
21: * TODO: document me.
22: */
23: public class MethodBindTest extends GWTTestCase {
24:
25: /**
26: * TODO: document me.
27: */
28: private static abstract class Abstract implements Go {
29: private final class Nested implements Go {
30: public void go() {
31: result = "wrong";
32: }
33:
34: void nestedTrigger() {
35: Abstract.this .go();
36: }
37: }
38:
39: private final class Nested2 extends Abstract {
40: public void go() {
41: result = "wrong";
42: }
43:
44: void nestedTrigger() {
45: Abstract.this .go();
46: }
47: }
48:
49: void trigger() {
50: new Nested().nestedTrigger();
51: }
52:
53: void trigger2() {
54: new Nested2().nestedTrigger();
55: }
56: }
57:
58: private final class Concrete extends Abstract {
59: public void go() {
60: result = "right";
61: }
62: }
63:
64: private interface Go {
65: void go();
66: }
67:
68: private static String result;
69:
70: public String getModuleName() {
71: return "com.google.gwt.dev.jjs.CompilerSuite";
72: }
73:
74: public void testMethodBinding() {
75: result = null;
76: new Concrete().trigger();
77: assertEquals("right", result);
78: result = null;
79: new Concrete().trigger2();
80: assertEquals("right", result);
81: }
82:
83: }
|