Tests: Moved `stx.libjava.tests.ExceptionTests` classes to mocks package
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 30 Mar 2016 18:53:20 +0100
changeset 3544 165835a0f082
parent 3543 bd2afe3a5a0d
child 3545 c67aed4cfdbc
Tests: Moved `stx.libjava.tests.ExceptionTests` classes to mocks package ...i.e., to `stx:libjava.tests.mocks.JavaExceptionTestsHelper. This makes it easier for ant task `test` to locate actual test cases and exclude mocks and test helpers.
JavaExceptionTests.st
tests/java/src/stx/libjava/tests/lang/ExceptionTests.java
tests/java/src/stx/libjava/tests/mocks/JavaExceptionTestsHelper.java
--- a/JavaExceptionTests.st	Sun Mar 27 00:41:25 2016 +0000
+++ b/JavaExceptionTests.st	Wed Mar 30 18:53:20 2016 +0100
@@ -92,13 +92,6 @@
     args := aMessage arguments.
     class := self class.
 
-    JavaLookup isNil ifTrue:[
-        (Smalltalk loadPackage: 'stx:libjava/experiments') ifFalse:[
-            self error: 'You should load package stx:libjava/experiments if you want some interop - still experimental' mayProceed: true.
-            ^nil                        
-        ]        
-    ].
-
     method := JavaLookup instance lookupMethodForSelector: selector
                 directedTo: class
                 for: self
@@ -134,7 +127,7 @@
     "
 
     | thrower caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [ 
         thrower throw_me: true.
         caught := false.
@@ -157,7 +150,7 @@
         2) Java method, does not IllegalArgumentException."
     
     | thrower  caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [
         thrower throw_me: false.
         caught := false.
@@ -183,7 +176,7 @@
     "
 
     | thrower caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [ 
         thrower throw_me: true.
         caught := false.
@@ -207,7 +200,7 @@
     "
 
     | thrower caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [
         [ 
             thrower throw_me: true.
@@ -235,7 +228,7 @@
     "
 
     | thrower caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [ 
         thrower call: true.
         caught := false.
@@ -259,7 +252,7 @@
         3) Java method, throws IllegalArgumentException."
     
     | thrower  caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [
         thrower test_03: true.
         caught := false.
@@ -283,7 +276,7 @@
         3) Smalltak method, throws 'signal'"
     
     | thrower  caught |
-    thrower := JAVA stx libjava tests lang ExceptionTests new.
+    thrower := JAVA stx libjava tests mocks JavaExceptionTestsHelper new.
     [
         thrower test_04: self with: true.
         caught := false.
--- a/tests/java/src/stx/libjava/tests/lang/ExceptionTests.java	Sun Mar 27 00:41:25 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-package  stx.libjava.tests.lang;
-
-import  java.lang.IllegalArgumentException;
-
-@stx.libjava.annotation.Package("stx:libjava/tests")
-public class ExceptionTests {
-
-    public int token = 0;
-
-    public void throw_me(boolean flag) {
-	if (flag)
-	    throw new IllegalArgumentException();
-    }
-
-    public void call(boolean flag) {
-	this.call(new ThrowCaller(), flag);
-    }
-
-    public void test_03(boolean do_throw) {
-	try {
-	    token = 1;
-	    if (do_throw)
-		throw new IllegalArgumentException();
-	    token = 2;
-	} finally {
-	    token = 3;
-	}
-    }
-
-    public void test_04(ThrowCaller thrower, boolean do_throw) {
-	try {
-	    token = 1;
-	    thrower.call(this, do_throw);
-	    token = 2;
-	} finally {
-	    token = 3;
-	}
-    }
-
-    public void call(ThrowCaller caller, boolean flag) {
-	caller.call(this, flag);
-    }
-
-    class ThrowCaller {
-	public void call(ExceptionTests inst, boolean flag) {
-	    inst.throw_me(flag);
-	}
-    };
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/java/src/stx/libjava/tests/mocks/JavaExceptionTestsHelper.java	Wed Mar 30 18:53:20 2016 +0100
@@ -0,0 +1,52 @@
+package  stx.libjava.tests.mocks;
+/**
+ * This class is used from Smalltalk test JavaExceptionTests
+ */
+
+import  java.lang.IllegalArgumentException;
+
+@stx.libjava.annotation.Package("stx:libjava/tests")
+public class JavaExceptionTestsHelper {
+
+    public int token = 0;
+
+    public void throw_me(boolean flag) {
+	if (flag)
+	    throw new IllegalArgumentException();
+    }
+
+    public void call(boolean flag) {
+	this.call(new ThrowCaller(), flag);
+    }
+
+    public void test_03(boolean do_throw) {
+	try {
+	    token = 1;
+	    if (do_throw)
+		throw new IllegalArgumentException();
+	    token = 2;
+	} finally {
+	    token = 3;
+	}
+    }
+
+    public void test_04(ThrowCaller thrower, boolean do_throw) {
+	try {
+	    token = 1;
+	    thrower.call(this, do_throw);
+	    token = 2;
+	} finally {
+	    token = 3;
+	}
+    }
+
+    public void call(ThrowCaller caller, boolean flag) {
+	caller.call(this, flag);
+    }
+
+    class ThrowCaller {
+	public void call(JavaExceptionTestsHelper inst, boolean flag) {
+	    inst.throw_me(flag);
+	}
+    };
+}