jaroslav@106
|
1 |
/**
|
jaroslav@106
|
2 |
* Back 2 Browser Bytecode Translator
|
jaroslav@106
|
3 |
* Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
|
jaroslav@106
|
4 |
*
|
jaroslav@106
|
5 |
* This program is free software: you can redistribute it and/or modify
|
jaroslav@106
|
6 |
* it under the terms of the GNU General Public License as published by
|
jaroslav@106
|
7 |
* the Free Software Foundation, version 2 of the License.
|
jaroslav@106
|
8 |
*
|
jaroslav@106
|
9 |
* This program is distributed in the hope that it will be useful,
|
jaroslav@106
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jaroslav@106
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jaroslav@106
|
12 |
* GNU General Public License for more details.
|
jaroslav@106
|
13 |
*
|
jaroslav@106
|
14 |
* You should have received a copy of the GNU General Public License
|
jaroslav@106
|
15 |
* along with this program. Look for COPYING file in the top folder.
|
jaroslav@106
|
16 |
* If not, see http://opensource.org/licenses/GPL-2.0.
|
jaroslav@106
|
17 |
*/
|
jaroslav@22
|
18 |
package org.apidesign.vm4brwsr;
|
jaroslav@0
|
19 |
|
jaroslav@789
|
20 |
import org.testng.annotations.AfterClass;
|
jaroslav@103
|
21 |
import org.testng.annotations.BeforeClass;
|
jaroslav@0
|
22 |
import org.testng.annotations.Test;
|
jaroslav@0
|
23 |
|
jaroslav@1409
|
24 |
/** Checks behavior of classes and methods with underscore.
|
jaroslav@0
|
25 |
*
|
jaroslav@0
|
26 |
* @author Jaroslav Tulach <jtulach@netbeans.org>
|
jaroslav@0
|
27 |
*/
|
jaroslav@1409
|
28 |
public class UnderTest {
|
jaroslav@1409
|
29 |
@Test public void one() throws Exception {
|
jaroslav@2
|
30 |
assertExec(
|
jaroslav@1409
|
31 |
"Should be one",
|
jaroslav@1409
|
32 |
Under_Score.class, "one__I",
|
jaroslav@173
|
33 |
Double.valueOf(1)
|
jaroslav@173
|
34 |
);
|
jaroslav@173
|
35 |
}
|
jaroslav@173
|
36 |
|
jaroslav@1409
|
37 |
@Test public void onePlusOne() throws Exception {
|
jaroslav@2
|
38 |
assertExec(
|
jaroslav@1409
|
39 |
"Should be two",
|
jaroslav@1409
|
40 |
Under_Score.class, "one_1plus_1one__I",
|
jaroslav@1409
|
41 |
Double.valueOf(2)
|
jaroslav@2
|
42 |
);
|
jaroslav@1
|
43 |
}
|
jaroslav@1
|
44 |
|
jaroslav@1409
|
45 |
@Test public void two() throws Exception {
|
jaroslav@48
|
46 |
assertExec(
|
jaroslav@1409
|
47 |
"Should be two",
|
jaroslav@1409
|
48 |
Under_Score.class, "two__I",
|
jaroslav@1409
|
49 |
Double.valueOf(2)
|
jaroslav@48
|
50 |
);
|
jaroslav@48
|
51 |
}
|
jaroslav@48
|
52 |
|
jaroslav@1409
|
53 |
@Test public void staticField() throws Exception {
|
jaroslav@2
|
54 |
assertExec(
|
jaroslav@1409
|
55 |
"Should be ten",
|
jaroslav@1409
|
56 |
Under_Score.class, "staticField__I",
|
jaroslav@1409
|
57 |
Double.valueOf(10)
|
jaroslav@600
|
58 |
);
|
jaroslav@600
|
59 |
}
|
jaroslav@600
|
60 |
|
jaroslav@1409
|
61 |
@Test public void instance() throws Exception {
|
jaroslav@600
|
62 |
assertExec(
|
jaroslav@1409
|
63 |
"Should be five",
|
jaroslav@1409
|
64 |
Under_Score.class, "instance__I",
|
jaroslav@1409
|
65 |
Double.valueOf(5)
|
jaroslav@600
|
66 |
);
|
jaroslav@600
|
67 |
}
|
jaroslav@600
|
68 |
|
jaroslav@291
|
69 |
|
jaroslav@708
|
70 |
private static TestVM code;
|
jaroslav@103
|
71 |
|
jaroslav@103
|
72 |
@BeforeClass
|
jaroslav@789
|
73 |
public static void compileTheCode() throws Exception {
|
jaroslav@103
|
74 |
StringBuilder sb = new StringBuilder();
|
jaroslav@1409
|
75 |
code = TestVM.compileClass(sb, "org/apidesign/vm4brwsr/Under_Score");
|
jaroslav@2
|
76 |
}
|
jaroslav@789
|
77 |
@AfterClass
|
jaroslav@789
|
78 |
public static void releaseTheCode() {
|
jaroslav@789
|
79 |
code = null;
|
jaroslav@789
|
80 |
}
|
jaroslav@2
|
81 |
|
jaroslav@708
|
82 |
private void assertExec(
|
jaroslav@708
|
83 |
String msg, Class<?> clazz, String method,
|
jaroslav@708
|
84 |
Object ret, Object... args
|
jaroslav@708
|
85 |
) throws Exception {
|
jaroslav@708
|
86 |
code.assertExec(msg, clazz, method, ret, args);
|
jaroslav@298
|
87 |
}
|
jaroslav@0
|
88 |
}
|