author | rfield |
Tue, 20 Nov 2012 09:58:55 -0800 | |
changeset 14554 | 4e29b285c723 |
child 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
14554
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
1 |
/* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
4 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
10 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
15 |
* accompanied this code). |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
16 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
20 |
* |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
23 |
* questions. |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
24 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
25 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
26 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
27 |
* @test |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
28 |
* @bug 8003639 |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
29 |
* @summary convert lambda testng tests to jtreg and add them |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
30 |
* @run testng LambdaTranslationTest1 |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
31 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
32 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
33 |
import org.testng.annotations.Test; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
34 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
35 |
import static org.testng.Assert.assertEquals; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
36 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
37 |
@Test |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
38 |
public class LambdaTranslationTest1 extends LT1Sub { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
39 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
40 |
String cntxt = "blah"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
41 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
42 |
private static final ThreadLocal<Object> result = new ThreadLocal<>(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
43 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
44 |
private static void setResult(Object s) { result.set(s); } |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
45 |
private static void appendResult(Object s) { result.set(result.get().toString() + s); } |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
46 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
47 |
private static void assertResult(String expected) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
48 |
assertEquals(result.get().toString(), expected); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
49 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
50 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
51 |
static Integer count(String s) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
52 |
return s.length(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
53 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
54 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
55 |
static int icount(String s) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
56 |
return s.length(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
57 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
58 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
59 |
static void eye(Integer i) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
60 |
setResult(String.format("I:%d", i)); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
61 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
62 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
63 |
static void ieye(int i) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
64 |
setResult(String.format("i:%d", i)); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
65 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
66 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
67 |
static void deye(double d) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
68 |
setResult(String.format("d:%f", d)); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
69 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
70 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
71 |
public void testLambdas() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
72 |
TBlock<Object> b = t -> {setResult("Sink0::" + t);}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
73 |
b.apply("Howdy"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
74 |
assertResult("Sink0::Howdy"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
75 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
76 |
TBlock<String> b1 = t -> {setResult("Sink1::" + t);}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
77 |
b1.apply("Rowdy"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
78 |
assertResult("Sink1::Rowdy"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
79 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
80 |
for (int i = 5; i < 10; ++i) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
81 |
TBlock<Integer> b2 = t -> {setResult("Sink2::" + t);}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
82 |
b2.apply(i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
83 |
assertResult("Sink2::" + i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
84 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
85 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
86 |
TBlock<Integer> b3 = t -> {setResult("Sink3::" + t);}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
87 |
for (int i = 900; i > 0; i -= 100) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
88 |
b3.apply(i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
89 |
assertResult("Sink3::" + i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
90 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
91 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
92 |
cntxt = "blah"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
93 |
TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
94 |
b4.apply("Yor"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
95 |
assertResult("b4: blah .. Yor"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
96 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
97 |
String flaw = "flaw"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
98 |
TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
99 |
b5.apply("BB"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
100 |
assertResult("b5: flaw .. BB"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
101 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
102 |
cntxt = "flew"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
103 |
TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
104 |
b6.apply("flee"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
105 |
assertResult("b6: flee .. flew .. flaw"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
106 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
107 |
TBlock<String> b7 = t -> {setResult(String.format("b7: %s %s", t, this.protectedSuperclassMethod()));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
108 |
b7.apply("this:"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
109 |
assertResult("b7: this: instance:flew"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
110 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
111 |
TBlock<String> b8 = t -> {setResult(String.format("b8: %s %s", t, super.protectedSuperclassMethod()));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
112 |
b8.apply("super:"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
113 |
assertResult("b8: super: I'm the sub"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
114 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
115 |
TBlock<String> b7b = t -> {setResult(String.format("b9: %s %s", t, protectedSuperclassMethod()));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
116 |
b7b.apply("implicit this:"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
117 |
assertResult("b9: implicit this: instance:flew"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
118 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
119 |
TBlock<Object> b10 = t -> {setResult(String.format("b10: new LT1Thing: %s", (new LT1Thing(t)).str));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
120 |
b10.apply("thing"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
121 |
assertResult("b10: new LT1Thing: thing"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
122 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
123 |
TBlock<Object> b11 = t -> {setResult(String.format("b11: %s", (new LT1Thing(t) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
124 |
String get() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
125 |
return "*" + str.toString() + "*"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
126 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
127 |
}).get()));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
128 |
b11.apply(999); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
129 |
assertResult("b11: *999*"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
130 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
131 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
132 |
public void testMethodRefs() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
133 |
LT1IA ia = LambdaTranslationTest1::eye; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
134 |
ia.doit(1234); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
135 |
assertResult("I:1234"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
136 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
137 |
LT1IIA iia = LambdaTranslationTest1::ieye; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
138 |
iia.doit(1234); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
139 |
assertResult("i:1234"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
140 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
141 |
LT1IA da = LambdaTranslationTest1::deye; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
142 |
da.doit(1234); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
143 |
assertResult("d:1234.000000"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
144 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
145 |
LT1SA a = LambdaTranslationTest1::count; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
146 |
assertEquals((Integer) 5, a.doit("howdy")); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
147 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
148 |
a = LambdaTranslationTest1::icount; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
149 |
assertEquals((Integer) 6, a.doit("shower")); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
150 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
151 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
152 |
public void testInner() throws Exception { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
153 |
(new In()).doInner(); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
154 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
155 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
156 |
protected String protectedSuperclassMethod() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
157 |
return "instance:" + cntxt; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
158 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
159 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
160 |
private class In { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
161 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
162 |
private int that = 1234; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
163 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
164 |
void doInner() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
165 |
TBlock<String> i4 = t -> {setResult(String.format("i4: %d .. %s", that, t));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
166 |
i4.apply("=1234"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
167 |
assertResult("i4: 1234 .. =1234"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
168 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
169 |
TBlock<String> i5 = t -> {setResult(""); appendResult(t); appendResult(t);}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
170 |
i5.apply("fruit"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
171 |
assertResult("fruitfruit"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
172 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
173 |
cntxt = "human"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
174 |
TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
175 |
b4.apply("bin"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
176 |
assertResult("b4: human .. bin"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
177 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
178 |
final String flaw = "flaw"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
179 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
180 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
181 |
Callable<String> c5 = () -> "["+flaw+"]" ; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
182 |
System.out.printf("c5: %s\n", c5.call() ); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
183 |
**/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
184 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
185 |
TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
186 |
b5.apply("BB"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
187 |
assertResult("b5: flaw .. BB"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
188 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
189 |
cntxt = "borg"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
190 |
TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
191 |
b6.apply("flee"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
192 |
assertResult("b6: flee .. borg .. flaw"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
193 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
194 |
TBlock<String> b7b = t -> {setResult(String.format("b7b: %s %s", t, protectedSuperclassMethod()));}; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
195 |
b7b.apply("implicit outer this"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
196 |
assertResult("b7b: implicit outer this instance:borg"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
197 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
198 |
/** |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
199 |
TBlock<Object> b9 = t -> { System.out.printf("New: %s\n", (new LT1Thing(t)).str); }; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
200 |
b9.apply("thing"); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
201 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
202 |
TBlock<Object> ba = t -> { System.out.printf("Def: %s\n", (new LT1Thing(t) { String get() { return "*" + str.toString() +"*";}}).get() ); }; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
203 |
ba.apply(999); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
204 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
205 |
*/ |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
206 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
207 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
208 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
209 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
210 |
class LT1Sub { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
211 |
protected String protectedSuperclassMethod() { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
212 |
return "I'm the sub"; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
213 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
214 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
215 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
216 |
class LT1Thing { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
217 |
final Object str; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
218 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
219 |
LT1Thing(Object s) { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
220 |
str = s; |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
221 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
222 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
223 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
224 |
interface LT1SA { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
225 |
Integer doit(String s); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
226 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
227 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
228 |
interface LT1IA { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
229 |
void doit(int i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
230 |
} |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
231 |
|
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
232 |
interface LT1IIA { |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
233 |
void doit(Integer i); |
4e29b285c723
8003639: convert lambda testng tests to jtreg and add them
rfield
parents:
diff
changeset
|
234 |
} |