Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 24, 2012
Danny Yoo correcting some of the stale tests to correct values e230087
Danny Yoo test cases running again bdb0d66
Danny Yoo adding test for map error 3772aa0
Commits on Jul 27, 2012
Danny Yoo adding a kludge to help with issue 66, but it's not quite the right s…
…olution because of things like '#(1 2 3), which will incorrectly be treated as '(vector 1 2 3)
16a4e1a
View
52 js-runtime/lib/browser-platform.js
@@ -50,37 +50,53 @@ var debugF = function(f_s) {
var deepEqual = function (obj1, obj2) {
- if (obj1 === obj2) {
- return true;
- }
+ if (obj1 === obj2) {
+ return true;
+ }
- for (var i in obj1) {
- if ( obj1.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
- if ( !(obj2.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
- return false;
- }
+ var i;
+ if (obj1 instanceof Array) {
+ if (obj2 instanceof Array) {
+ for (i = 0; i < obj1.length; i++) {
+ if (! deepEqual(obj1[i], obj2[i])) { return false; }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ if (typeof(obj1) === 'string' || typeof(obj1) === 'number') {
+ return obj1 === obj2;
+ }
+
+ for (var i in obj1) {
+ if ( obj1.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
+ if ( !(obj2.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
+ return false;
}
- for (var i in obj2) {
- if ( obj2.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
- if ( !(obj1.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
- return false;
- }
+ }
+ for (var i in obj2) {
+ if ( obj2.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
+ if ( !(obj1.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
+ return false;
}
- return true;
+ }
+ return true;
}
var assert = {};
assert.equal = function(x, y) {
- if (x !== y) {
- throw new Error('AssertError: ' + x + ' equal ' + y);
- }
+ if (x !== y) {
+ throw new Error('AssertError: ' + x + ' equal ' + y);
+ }
}
assert.deepEqual = function(x, y) {
if ( !deepEqual(x, y) ) {
- throw new Error('AssertError: ' + x + ' deepEqual ' + y);
+ throw new Error('AssertError: ' + x + ' deepEqual ' + y);
}
}
View
52 servlet-htdocs/support.js
@@ -50,37 +50,53 @@ var debugF = function(f_s) {
var deepEqual = function (obj1, obj2) {
- if (obj1 === obj2) {
- return true;
- }
+ if (obj1 === obj2) {
+ return true;
+ }
- for (var i in obj1) {
- if ( obj1.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
- if ( !(obj2.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
- return false;
- }
+ var i;
+ if (obj1 instanceof Array) {
+ if (obj2 instanceof Array) {
+ for (i = 0; i < obj1.length; i++) {
+ if (! deepEqual(obj1[i], obj2[i])) { return false; }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ if (typeof(obj1) === 'string' || typeof(obj1) === 'number') {
+ return obj1 === obj2;
+ }
+
+ for (var i in obj1) {
+ if ( obj1.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
+ if ( !(obj2.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
+ return false;
}
- for (var i in obj2) {
- if ( obj2.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
- if ( !(obj1.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
- return false;
- }
+ }
+ for (var i in obj2) {
+ if ( obj2.hasOwnProperty(i) && i !== '_eqHashCode' && i !== '_isList') {
+ if ( !(obj1.hasOwnProperty(i) && deepEqual(obj1[i], obj2[i])) )
+ return false;
}
- return true;
+ }
+ return true;
}
var assert = {};
assert.equal = function(x, y) {
- if (x !== y) {
- throw new Error('AssertError: ' + x + ' equal ' + y);
- }
+ if (x !== y) {
+ throw new Error('AssertError: ' + x + ' equal ' + y);
+ }
}
assert.deepEqual = function(x, y) {
if ( !deepEqual(x, y) ) {
- throw new Error('AssertError: ' + x + ' deepEqual ' + y);
+ throw new Error('AssertError: ' + x + ' deepEqual ' + y);
}
}
View
51 src/stx-helpers.ss
@@ -6,22 +6,35 @@
;; syntax->stx: syntax -> stx
;; Go from Scheme's syntax objects to our own.
(define (syntax->stx a-syntax)
- (cond
- [(pair? (syntax-e a-syntax))
- (let ([elts
- (map syntax->stx (syntax->list a-syntax))])
- (datum->stx #f
- elts
- (make-Loc (syntax-position a-syntax)
- (syntax-line a-syntax)
- (syntax-column a-syntax)
- (syntax-span a-syntax)
- (format "~a" (syntax-source a-syntax)))))]
- [else
- (datum->stx #f
- (syntax-e a-syntax)
- (make-Loc (syntax-position a-syntax)
- (syntax-line a-syntax)
- (syntax-column a-syntax)
- (syntax-span a-syntax)
- (format "~a" (syntax-source a-syntax))))]))
+ (let ([a-loc (make-Loc (syntax-position a-syntax)
+ (syntax-line a-syntax)
+ (syntax-column a-syntax)
+ (syntax-span a-syntax)
+ (format "~a" (syntax-source a-syntax)))])
+ (cond
+ [(pair? (syntax-e a-syntax))
+ (let ([elts
+ (map syntax->stx (syntax->list a-syntax))])
+ (datum->stx #f
+ elts
+ a-loc))]
+
+ ;; Kludge: stx currently only supports atoms and lists, not boxes.
+ ;; This needs to be fixed by extending stx's definition.
+ [(box? (syntax-e a-syntax))
+ (let ([val (syntax->stx (unbox (syntax-e a-syntax)))])
+ (datum->stx #f
+ `(,(datum->stx #f 'box a-loc) ,val)
+ a-loc))]
+
+ ;; Kludge: stx currently only supports atoms and lists, not vectors.
+ ;; This needs to be fixed by extending stx's definition.
+ [(vector? (syntax-e a-syntax))
+ (let ([vals (map syntax->stx (vector->list (syntax-e a-syntax)))])
+ (datum->stx #f
+ `(,(datum->stx #f 'vector a-loc) ,@vals)
+ a-loc))]
+ [else
+ (datum->stx #f
+ (syntax-e a-syntax)
+ a-loc)])))
View
72 tests/test-htdocs/test-main.js
@@ -298,8 +298,8 @@ var runTests = function() {
var runAsyncTests = function(i, k) {
if (i < asyncTests.length) {
- runAsyncTest(asyncTests.name,
- asyncTests.f,
+ runAsyncTest(asyncTests[i].name,
+ asyncTests[i].f,
function() {
setTimeout(function() {
runAsyncTests(i+1, k);
@@ -323,7 +323,7 @@ var runTests = function() {
sys.print('\n');
};
try {
- f(succeed, fail);
+ f(success, fail);
} catch(e) {
fail(e);
}
@@ -1704,17 +1704,17 @@ var runTests = function() {
testPrim('format', runtime.string, ['hello'], runtime.string('hello'));
testPrim('format', id, ['hello~n'], runtime.string('hello\n'));
testPrim('format', id, [runtime.string('Test: ~a~nTest2: ~A~%'),
- runtime.char('A'),
- runtime.list([1, 2, 3])],
- runtime.string('Test: A\nTest2: (1 2 3)\n'));
+ runtime.char('A'),
+ runtime.list([1, 2, 3])],
+ runtime.string('Test: A\nTest2: (list 1 2 3)\n'));
testPrim('format', id, ['~s ~S ~a',
- runtime.char('b'),
- runtime.complex(0, 2),
- runtime.char('b')],
- runtime.string('#\\b 0+2i b'));
-
+ runtime.char('b'),
+ runtime.complex(0, 2),
+ runtime.char('b')],
+ runtime.string('#\\b 0+2i b'));
+
testPrim('format', id, ['~s ~a', primitive.getPrimitive('+'), primitive.getPrimitive('format')],
- runtime.string('#<procedure:+> #<procedure:format>'));
+ runtime.string('#<procedure:+> #<procedure:format>'));
var box1 = types.box('junk');
var box2 = types.box(box1);
@@ -1727,6 +1727,8 @@ var runTests = function() {
});
+
+
runRawTest('explode',
function() {
testPrim('explode', id, [''], runtime.EMPTY);
@@ -2150,13 +2152,13 @@ var runTests = function() {
runRawTest('floor, ceiling, and round',
function() {
testPrim('floor', id, [14], 14);
- testPrim('floor', runtime.float, [12.56], 12);
+ testPrim('floor', runtime.float, [12.56], runtime.float(12));
testPrim('ceiling', id, [13], 13);
- testPrim('ceiling', runtime.float, [12.23], 13);
- testPrim('ceiling', runtime.float, [12.00], 12);
+ testPrim('ceiling', runtime.float, [12.23], runtime.float(13));
+ testPrim('ceiling', runtime.float, [12.00], runtime.float(12.0));
testPrim('round', id, [124], 124);
- testPrim('round', runtime.float, [12.432], 12);
- testPrim('round', runtime.float, [12.543], 13);
+ testPrim('round', runtime.float, [12.432], runtime.float(12));
+ testPrim('round', runtime.float, [12.543], runtime.float(13));
});
@@ -2188,8 +2190,8 @@ var runTests = function() {
runRawTest('sin, cos, tan, asin, acos, atan',
function() {
testPrim('sin', id, [20], runtime.float(Math.sin(20)));
- testPrim('sin', id, [0], runtime.float(0));
- testPrim('cos', id, [0], runtime.float(1));
+ testPrim('sin', id, [0], 0);
+ testPrim('cos', id, [0], 1);
testPrim('cos', runtime.float, [43], runtime.float(Math.cos(43)));
testPrim('tan', runtime.float, [0], runtime.float(0));
testPrim('tan', id, [-30], runtime.float(Math.tan(-30)));
@@ -3578,6 +3580,38 @@ var runTests = function() {
+ queueAsyncTest("test-map", function(success, fail) {
+
+ var checkOutput = function(err) {
+ if (evaluator.getMessageFromExn(err) ===
+ 'add1: expects argument of type <number>, given: "1"') {
+ success();
+ } else {
+ fail();
+ }
+ };
+
+ var evaluator = new Evaluator(
+ { write: function(x) { },
+ writeError: function(err) { },
+ compilationServletUrl: "/servlets/standalone.ss",
+ scriptCompilationServletUrl: "/servlets/standalone.ss"
+ });
+
+ evaluator.setRootLibraryPath("/collects");
+ evaluator.executeProgram('test-map',
+ '(map add1 (list "1"))',
+ checkOutput,
+ checkOutput);
+ });
+
+
+
+
+
+
+
+
sys.print("Running asynchronous tests...\n");
runAsyncTests(0, function(){

No commit comments for this range

Something went wrong with that request. Please try again.