Permalink
Browse files

nodeunit test-list

  • Loading branch information...
ajlopez committed May 17, 2012
1 parent 782058a commit e05049274039c3661952d7254049960938f083d3
Showing with 63 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 nodeunit.cmd
  3. +61 −0 test/test-list.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -0,0 +1 @@
+node node_modules\nodeunit\bin\nodeunit %*
View
@@ -0,0 +1,61 @@
+
+var ajlisp = require('../lib/ajlisp');
+
+exports['Dotted List'] = function(test) {
+ var list = new ajlisp.List(1,2);
+
+ test.equal(list.first(), 1);
+ test.equal(list.rest(), 2);
+ test.equal(list.isAtom(),false);
+ test.equal(list.isList(),true);
+ test.equal(ajlisp.isAtom(list), false);
+ test.equal(ajlisp.isList(list), true);
+ test.equal(list.asString(), "(1.2)");
+
+ test.done();
+};
+
+exports['Compare Dotted Lists'] = function(test) {
+ var list = new ajlisp.List(1,2);
+ var list2 = new ajlisp.List(1,2);
+
+ test.equal(list.equals(list2), true);
+ test.equal(list2.equals(list), true);
+
+ test.done();
+};
+
+exports['Make List'] = function(test) {
+ var list = ajlisp.makeList(1,2,3);
+
+ test.ok(list.isList());
+ test.equal(list.first(), 1);
+ test.equal(list.rest().first(), 2);
+ test.equal(list.rest().rest().first(), 3);
+
+ test.done();
+};
+
+exports['Make List with Nulls'] = function(test) {
+ var list = ajlisp.makeList(null, null);
+
+ test.ok(list.isList());
+ test.equal(list.first(), null);
+ test.equal(list.rest().first(), null);
+
+ test.done();
+};
+
+exports['List as Array'] = function(test) {
+ var list = ajlisp.makeList(1,2,3);
+ var result = list.asArray();
+
+ test.ok(result);
+ test.equal(result.length, 3);
+ test.equal(result[0], 1);
+ test.equal(result[1], 2);
+ test.equal(result[2], 3);
+
+ test.done();
+};
+

0 comments on commit e050492

Please sign in to comment.