Revision: 2008
http://vexi.svn.sourceforge.net/vexi/?rev=2008&view=rev
Author: mkpg2
Date: 2007-07-27 08:32:44 -0700 (Fri, 27 Jul 2007)
Log Message:
-----------
Test. Simple test for JustTrigger traps.
Added Paths:
-----------
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.java
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.js
Added:
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.java
===================================================================
---
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.java
(rev 0)
+++
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.java
2007-07-27 15:32:44 UTC (rev 2008)
@@ -0,0 +1,109 @@
+package test.js.exec.traps.just_trigger;
+
+import java.io.File;
+import java.net.URL;
+
+import org.ibex.js.Interpreter;
+import org.ibex.js.JS;
+import org.ibex.js.JSExn;
+import org.ibex.js.JSU;
+import org.ibex.js.RunJS;
+import org.ibex.js.JS.Trap;
+import org.ibex.util.Log;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import test.Util;
+import test.js.exec.JSTestSuite;
+import test.js.exec.general.TestGeneral;
+import test.js.exec.traps.range.TestRangeTraps;
+
+/**
+ * @author mike
+ */
+public class TestJustTrigger extends TestCase {
+
+ static JS record;
+ static JS.Obj testobj;
+ /*
+ static class JS_A extends JS.Obj{
+ // COPIED from Box.jpp
+
+ private Trap wtrap(JS name){
+ Trap t = (Trap)super.get(name, 1);
+ return t==null?null:t.write();
+ }
+
+ private final boolean prePutTriggerTrapsAndCatchExceptions(JS name,
JS val) {
+ try {
+ Trap t = wtrap(name);
+ if(t!=null) org.ibex.js.Thread.runBeforePut(t, val);
+ } catch (JSExn e) {
+ Log.uWarn(TestPauseOnPut.class,"Caught JS Exception while
putting to trap \""+name+"\"");
+ Log.uWarn(TestPauseOnPut.class,e);
+ return true;
+ }
+ return false;
+
+ }
+
+ private final void postPutTriggerTrapsAndCatchExceptions(JS name,
boolean b) {
+ try {
+ Trap t = wtrap(name);
+ if(t!=null) org.ibex.js.Thread.runAfterPut(b);
+ } catch (JSExn e) {
+ Log.uWarn(TestPauseOnPut.class,"Caught JS Exception while
putting to trap \""+name+"\"");
+ Log.uWarn(TestPauseOnPut.class,e);
+ }
+ }
+ ///
+ // Testing pre and post putting
+ public void putAndTriggerTrapsIgnoreCascade(JS name, JS val) throws
JSExn{
+ boolean b = prePutTriggerTrapsAndCatchExceptions(name, val);
+ put(name, val);
+ postPutTriggerTrapsAndCatchExceptions(name, b);
+ }
+
+ public void put(JS key, JS val) throws JSExn {
+ super.put(key, val);
+ }
+
+ public JS get(JS key) throws JSExn {
+ return super.get(key);
+ }
+ }*/
+
+
+
+ public static void main(String[] args) throws Exception {
+ TestJustTrigger t = new TestJustTrigger();
+ t.setUp();
+ t.testSimple();
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ if(record==null){
+ record = new JS.Obj();
+ testobj = new JS.Obj();
+ URL dir =
TestJustTrigger.class.getResource("TestJustTrigger.js");
+ String path = new File(dir.getPath()).getParent();
+ RunJS.runJSFile(new String[]{path},
"TestJustTrigger.js", new String[]{"testobj","record"}, new
JS[]{testobj,record});
+ }
+ }
+
+ public void testSimple() throws JSExn{
+ final JS key = JSU.S("A");
+ final JS val = JSU.N(1);
+ JS r = testobj.justTriggerTraps(key, val);
+ assertEquals(Interpreter.CASCADE_PREVENTED, r);
+ assertNull(record.get(JSU.S("A1")));
+ assertNotNull(record.get(JSU.S("A2")));
+ }
+
+ public static Test suite() {
+ return Util.suiteJava(TestJustTrigger.class);
+ }
+}
Added:
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.js
===================================================================
---
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.js
(rev 0)
+++
core/trunk/org.ibex.js/src_junit/test/js/exec/traps/just_trigger/TestJustTrigger.js
2007-07-27 15:32:44 UTC (rev 2008)
@@ -0,0 +1,18 @@
+sys.log.info("Adding traps for just trigger tests");
+var testobj = sys.testobj;
+
+// Simple case
+testobj.A ++= function(v){
+ //unreached - obscured
+ sys.record["A1"] = 1;
+ cascade = v;
+};
+
+testobj.A ++= function(v){
+ sys.record["A2"] = 1;
+ return;
+};
+
+
+
+
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn