001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.dev.jjs.test;
017:
018: import com.google.gwt.junit.client.GWTTestCase;
019:
020: /**
021: * TODO: document me.
022: */
023: public class InnerOuterSuperTest extends GWTTestCase {
024:
025: /**
026: * TODO: document me.
027: */
028: public static class Outer {
029:
030: /**
031: * TODO: document me.
032: */
033: public class OuterIsNotSuper {
034:
035: public int getValue() {
036: return value;
037: }
038: }
039:
040: /**
041: * TODO: document me.
042: */
043: public class OuterIsSuper extends Outer {
044:
045: public OuterIsSuper(int i) {
046: super (i);
047: }
048:
049: public int checkDispatch() {
050: return 2;
051: }
052:
053: public int checkDispatchFromSub1() {
054: return super .checkDispatch();
055: }
056:
057: public int checkDispatchFromSub2() {
058: return new Outer(1) {
059: public int go() {
060: return OuterIsSuper.super .checkDispatch();
061: }
062: }.go();
063: }
064:
065: public OuterIsNotSuper unqualifiedAlloc() {
066: return new OuterIsNotSuper();
067: }
068: }
069:
070: /**
071: * TODO: document me.
072: */
073: public static class TestQualifiedSuperCall extends
074: OuterIsNotSuper {
075: public TestQualifiedSuperCall() {
076: new Outer(1).new OuterIsSuper(2).super ();
077: }
078: }
079:
080: /**
081: * TODO: document me.
082: */
083: public class TestUnqualifiedSuperCall extends OuterIsNotSuper {
084: public TestUnqualifiedSuperCall() {
085: super ();
086: }
087: }
088:
089: protected final int value;
090:
091: public Outer(int i) {
092: value = i;
093: }
094:
095: public int checkDispatch() {
096: return 1;
097: }
098: }
099:
100: private final Outer outer = new Outer(1);
101:
102: private final Outer.OuterIsSuper outerIsSuper = outer.new OuterIsSuper(
103: 2);
104:
105: public String getModuleName() {
106: return "com.google.gwt.dev.jjs.CompilerSuite";
107: }
108:
109: public void testOuterIsNotSuper() {
110: Outer.OuterIsNotSuper x = outerIsSuper.new OuterIsNotSuper();
111: assertEquals(2, x.getValue());
112: }
113:
114: public void testOuterIsNotSuperAnon() {
115: Outer.OuterIsNotSuper x = outerIsSuper.new OuterIsNotSuper() {
116: };
117: assertEquals(2, x.getValue());
118: }
119:
120: public void testQualifiedSuperCall() {
121: Outer.TestQualifiedSuperCall x = new Outer.TestQualifiedSuperCall();
122: assertEquals(2, x.getValue());
123: }
124:
125: public void testQualifiedSuperCallAnon() {
126: Outer.TestQualifiedSuperCall x = new Outer.TestQualifiedSuperCall() {
127: };
128: assertEquals(2, x.getValue());
129: }
130:
131: public void testSuperDispatch() {
132: assertEquals(1, outerIsSuper.checkDispatchFromSub1());
133: assertEquals(1, outerIsSuper.checkDispatchFromSub2());
134: }
135:
136: public void testUnqualifiedAlloc() {
137: Outer.OuterIsNotSuper x = outerIsSuper.unqualifiedAlloc();
138: assertEquals(2, x.getValue());
139: }
140:
141: public void testUnqualifiedSuperCall() {
142: Outer.TestUnqualifiedSuperCall x = outerIsSuper.new TestUnqualifiedSuperCall();
143: assertEquals(2, x.getValue());
144: }
145:
146: public void testUnqualifiedSuperCallAnon() {
147: Outer.TestUnqualifiedSuperCall x = outerIsSuper.new TestUnqualifiedSuperCall() {
148: };
149: assertEquals(2, x.getValue());
150: }
151: }
|