Skip to content
Browse files

adding more stuff from test harness

  • Loading branch information...
1 parent 103f800 commit fbf2978830681ee32ee6e4504fde6cd864a70e46 @qmx qmx committed May 3, 2012
View
6 src/test/java/org/dynjs/spec/DynJSTestRunner.java
@@ -18,16 +18,14 @@
import org.dynjs.runtime.DynJS;
import org.dynjs.runtime.DynJSConfig;
import org.dynjs.runtime.DynThreadContext;
-import org.junit.internal.AssumptionViolatedException;
+import org.dynjs.spec.shims.FailShim;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
-import org.mockito.internal.matchers.Equals;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -45,6 +43,7 @@ public DynJSTestRunner(Class<?> testClass) {
this.testClass = testClass;
init();
DynJSConfig config = new DynJSConfig();
+ config.addBuiltin("$$$fail", new FailShim());
dynJS = new DynJS(config);
}
@@ -103,4 +102,5 @@ public void run(RunNotifier notifier) {
}
}
}
+
}
View
4 src/test/java/org/dynjs/spec/Ecma262Test.java
@@ -24,13 +24,13 @@
new AndFileFilter(new SuffixFileFilter("js"),
new NotFileFilter(new NameFileFilter(BLACKLIST))),
TrueFileFilter.INSTANCE);
-// return FileUtils.listFiles(new File(resource.toURI()), new String[]{"js"}, true);
}
throw new RuntimeException("failed loading test suite");
}
public static Collection<File> filesToPreload() throws URISyntaxException {
- return Arrays.asList(new File(Ecma262Test.class.getResource("/harness/cth.js").toURI())
+ return Arrays.asList(new File(Ecma262Test.class.getResource("/harness/cth.js").toURI()),
+ new File(Ecma262Test.class.getResource("/harness/sta-lite.js").toURI())
//new File(Ecma262Test.class.getResource("/harness/ed.js").toURI()),
// new File(Ecma262Test.class.getResource("/harness/framework.js").toURI())
);
View
98 src/test/java/org/dynjs/spec/shims/FailShim.java
@@ -0,0 +1,98 @@
+package org.dynjs.spec.shims;
+
+import org.dynjs.exception.DynJSException;
+import sun.org.mozilla.javascript.internal.Context;
+import sun.org.mozilla.javascript.internal.Function;
+import sun.org.mozilla.javascript.internal.Scriptable;
+
+public class FailShim implements Function {
+ @Override
+ public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
+ throw new DynJSException(objects.length == 1 ? objects[0].toString() : "failed");
+ }
+
+ @Override
+ public Scriptable construct(Context context, Scriptable scriptable, Object[] objects) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String getClassName() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object get(String s, Scriptable scriptable) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object get(int i, Scriptable scriptable) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean has(String s, Scriptable scriptable) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean has(int i, Scriptable scriptable) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void put(String s, Scriptable scriptable, Object o) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void put(int i, Scriptable scriptable, Object o) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void delete(String s) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void delete(int i) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Scriptable getPrototype() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setPrototype(Scriptable scriptable) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Scriptable getParentScope() {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public void setParentScope(Scriptable scriptable) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object[] getIds() {
+ return new Object[0]; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public Object getDefaultValue(Class<?> aClass) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean hasInstance(Scriptable scriptable) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
View
21 src/test/resources/harness/sta-lite.js
@@ -0,0 +1,21 @@
+function testFailed(message) {
+ $$$fail(message);
+}
+
+//function $PRINT(message) {
+//
+//}
+//
+//function $INCLUDE(message) { }
+function $ERROR(message) {
+ testFailed(message);
+}
+//
+//function $FAIL(message) {
+// testFailed(message);
+//}
+//
+function runTestCase(testcase) {
+ var x = testcase();
+ print(x);
+}

0 comments on commit fbf2978

Please sign in to comment.
Something went wrong with that request. Please try again.