diff graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java @ 21490:3286fb5fea4a

Introducing standard I/O and error into Env and using TruffleVM to execute SL test cases. Adding SLTckTest to verify SL language interop.
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Tue, 26 May 2015 19:11:36 +0200
parents 99942eac9c6d
children 31fc2fce38f3 e59895e16377
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java	Tue May 26 16:46:25 2015 +0200
+++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java	Tue May 26 19:11:36 2015 +0200
@@ -24,16 +24,17 @@
 
 import com.oracle.truffle.api.vm.TruffleVM;
 import java.util.Random;
+import org.junit.Test;
 
 /**
  * A collection of tests that can certify language implementaiton to be complient with most recent
  * requirements of the Truffle infrastructure and tooling. Subclass, implement abstract methods and
  * include in your test suite.
  */
-public abstract class TruffleTCK {
-    private TruffleVM vm;
+public class TruffleTCK { // abstract
+    private TruffleVM tckVM;
 
-    protected TruffleTCK() {
+    public TruffleTCK() { // protected
     }
 
     /**
@@ -45,8 +46,11 @@
      * for internal testing.
      *
      * @return initialized Truffle virtual machine
+     * @throws java.lang.Exception thrown when the VM preparation fails
      */
-    protected abstract TruffleVM prepareVM() throws Exception;
+    protected TruffleVM prepareVM() throws Exception { // abstract
+        return null;
+    }
 
     /**
      * Name of function which will return value 42 as a number. The return value of the method
@@ -55,7 +59,9 @@
      *
      * @return name of globally exported symbol
      */
-    protected abstract String fourtyTwo();
+    protected String fourtyTwo() { // abstract
+        return null;
+    }
 
     /**
      * Name of function to add two integer values together. The symbol will be invoked with two
@@ -64,20 +70,26 @@
      *
      * @return name of globally exported symbol
      */
-    protected abstract String plusInt();
+    protected String plusInt() {  // abstract
+        return null;
+    }
 
     private TruffleVM vm() throws Exception {
-        if (vm == null) {
-            vm = prepareVM();
+        if (tckVM == null) {
+            tckVM = prepareVM();
         }
-        return vm;
+        return tckVM;
     }
 
     //
     // The tests
     //
 
+    @Test
     public void testFortyTwo() throws Exception {
+        if (getClass() == TruffleTCK.class) {
+            return;
+        }
         TruffleVM.Symbol fourtyTwo = findGlobalSymbol(fourtyTwo());
 
         Object res = fourtyTwo.invoke(null);
@@ -89,7 +101,11 @@
         assert 42 == n.intValue() : "The value is 42 =  " + n.intValue();
     }
 
+    @Test
     public void testPlusWithInts() throws Exception {
+        if (getClass() == TruffleTCK.class) {
+            return;
+        }
         Random r = new Random();
         int a = r.nextInt(100);
         int b = r.nextInt(100);