aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-23 22:42:00 -0500
committerJoel Martin <github@martintribe.org>2014-04-23 22:42:00 -0500
commite6a1697802135bf29a1ed50074d9244653235e4b (patch)
tree09e42c10cf02ac8ac4dcb1b49d45568c838058bc
parent37b97ee7a874b4b881733477e4633914f41d1106 (diff)
downloadmal-e6a1697802135bf29a1ed50074d9244653235e4b.tar.gz
mal-e6a1697802135bf29a1ed50074d9244653235e4b.zip
JS: Fix internal tests.
Thanks: Wes Brown <wesbrown18@gmail.com>.
-rw-r--r--js/tests/reader.js13
-rw-r--r--js/tests/types.js24
2 files changed, 20 insertions, 17 deletions
diff --git a/js/tests/reader.js b/js/tests/reader.js
index 2aa81c6..132ec4f 100644
--- a/js/tests/reader.js
+++ b/js/tests/reader.js
@@ -1,9 +1,10 @@
common = require('./common.js');
types = require('../types');
reader = require('../reader');
+core = require('../core');
var assert_eq = common.assert_eq,
read_str = reader.read_str,
- nth = types.ns.nth;
+ nth = core.ns.nth;
console.log("Testing read of constants/strings");
assert_eq(2,read_str('2'));
@@ -13,7 +14,7 @@ assert_eq('abc',read_str('"abc"'));
assert_eq('a string (with parens)',read_str('"a string (with parens)"'));
console.log("Testing read of symbols");
-assert(types.symbol_Q(read_str('abc')));
+assert(types._symbol_Q(read_str('abc')));
assert_eq('abc',read_str('abc').value);
assert_eq('.',read_str('.').value);
@@ -32,11 +33,11 @@ assert_eq('"xyz"',read_str('"\\"xyz\\""'));
console.log("Testing READ_STR of lists");
-assert_eq(2,types.ns.count(read_str('(2 3)')));
-assert_eq(2,types.ns.first(read_str('(2 3)')));
-assert_eq(3,types.ns.first(types.ns.rest(read_str('(2 3)'))));
+assert_eq(2,core.ns.count(read_str('(2 3)')));
+assert_eq(2,core.ns.first(read_str('(2 3)')));
+assert_eq(3,core.ns.first(core.ns.rest(read_str('(2 3)'))));
L = read_str('(+ 1 2 "str1" "string (with parens) and \'single quotes\'")');
-assert_eq(5,types.ns.count(L));
+assert_eq(5,core.ns.count(L));
assert_eq('str1',nth(L,3));
assert_eq('string (with parens) and \'single quotes\'',nth(L,4));
assert_eq([2,3],read_str('(2 3)'));
diff --git a/js/tests/types.js b/js/tests/types.js
index 71b276f..d200cf7 100644
--- a/js/tests/types.js
+++ b/js/tests/types.js
@@ -1,15 +1,17 @@
common = require('./common.js');
var assert_eq = common.assert_eq;
var types = require('../types.js');
-var symbol = types.symbol,
- hash_map = types.ns['hash-map'],
- hash_map_Q = types.ns['map?'],
- assoc = types.ns['assoc'],
- dissoc = types.ns['dissoc'],
- get = types.ns['get'],
- contains_Q = types.ns['contains?'],
- count = types.ns['count'],
- equal_Q = types.ns['='];
+var core = require('../core.js');
+var env = require('../env.js');
+var symbol = types._symbol,
+ hash_map = core.ns['hash-map'],
+ hash_map_Q = core.ns['map?'],
+ assoc = core.ns['assoc'],
+ dissoc = core.ns['dissoc'],
+ get = core.ns['get'],
+ contains_Q = core.ns['contains?'],
+ count = core.ns['count'],
+ equal_Q = core.ns['='];
console.log("Testing hash_maps");
@@ -73,7 +75,7 @@ assert_eq(false, equal_Q(L10, L6));
console.log("Testing ENV (1 level)")
-env1 = new types.Env();
+env1 = new env.Env();
assert_eq('val_a',env1.set('a','val_a'));
assert_eq('val_b',env1.set('b','val_b'));
assert_eq('val_eq',env1.set('=','val_eq'));
@@ -82,7 +84,7 @@ assert_eq('val_b',env1.get('b'));
assert_eq('val_eq',env1.get('='));
console.log("Testing ENV (2 levels)");
-env2 = new types.Env(env1);
+env2 = new env.Env(env1);
assert_eq('val_b2',env2.set('b','val_b2'));
assert_eq('val_c',env2.set('c','val_c'));
assert_eq(env1,env2.find('a'));