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