aboutsummaryrefslogtreecommitdiffstats
path: root/website/resources/scripts/global/framework.js
diff options
context:
space:
mode:
Diffstat (limited to 'website/resources/scripts/global/framework.js')
-rw-r--r--website/resources/scripts/global/framework.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/website/resources/scripts/global/framework.js b/website/resources/scripts/global/framework.js
new file mode 100644
index 000000000..04164e18c
--- /dev/null
+++ b/website/resources/scripts/global/framework.js
@@ -0,0 +1,79 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+function Test262Error(message) {
+ this.message = message;
+}
+
+Test262Error.prototype.toString = function () {
+ return "Test262 Error: " + this.message;
+};
+
+function testFailed(message) {
+ throw new Test262Error(message);
+}
+
+function testPrint(message) {
+
+}
+
+/**
+ * It is not yet clear that runTestCase should pass the global object
+ * as the 'this' binding in the call to testcase.
+ */
+var runTestCase = (function(global) {
+ return function(testcase) {
+ if (!testcase.call(global)) {
+ testFailed('test function returned falsy');
+ }
+ };
+})(this);
+
+function assertTruthy(value) {
+ if (!value) {
+ testFailed('test return falsy');
+ }
+}
+
+
+/**
+ * falsy means we expect no error.
+ * truthy means we expect some error.
+ * A non-empty string means we expect an error whose .name is that string.
+ */
+var expectedErrorName = false;
+
+/**
+ * What was thrown, or the string 'Falsy' if something falsy was thrown.
+ * null if test completed normally.
+ */
+var actualError = null;
+
+function testStarted(expectedErrName) {
+ expectedErrorName = expectedErrName;
+}
+
+function testFinished() {
+ var actualErrorName = actualError && (actualError.name ||
+ 'SomethingThrown');
+ if (actualErrorName) {
+ if (expectedErrorName) {
+ if (typeof expectedErrorName === 'string') {
+ if (expectedErrorName === actualErrorName) {
+ return;
+ }
+ testFailed('Threw ' + actualErrorName +
+ ' instead of ' + expectedErrorName);
+ }
+ return;
+ }
+ throw actualError;
+ }
+ if (expectedErrorName) {
+ if (typeof expectedErrorName === 'string') {
+ testFailed('Completed instead of throwing ' +
+ expectedErrorName);
+ }
+ testFailed('Completed instead of throwing');
+ }
+}