1
0
Fork 0

added tests for coffee script

This commit is contained in:
Jan Steemann 2014-03-21 09:22:20 +01:00
parent 2d7a586cc6
commit 7c28db24af
3 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# a CoffeeScript test file
exports.coffeeSquare = (x) -> x * x
exports.coffeeValue = "test"

View File

@ -0,0 +1,10 @@
{
"tags" : [ "foo", "bar", "baz" ],
"author" : {
"first" : "foo",
"last" : "bar"
},
"number" : 42,
"sensible" : false,
"nullValue" : null
}

View File

@ -63,6 +63,49 @@ function RequireTestSuite () {
module.root.unloadAll();
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test requiring JSON
////////////////////////////////////////////////////////////////////////////////
testRequireJson : function () {
var test = createTestPackage();
var data = test.require("test-data");
assertTrue(data.hasOwnProperty("tags"));
assertEqual([ "foo", "bar", "baz" ], data.tags);
assertTrue(data.hasOwnProperty("author"));
assertEqual({ "first" : "foo", "last" : "bar" }, data.author);
assertTrue(data.hasOwnProperty("number"));
assertEqual(42, data.number);
assertTrue(data.hasOwnProperty("sensible"));
assertFalse(data.sensible);
assertTrue(data.hasOwnProperty("nullValue"));
assertNull(data.nullValue);
assertFalse(data.hasOwnProperty("schabernack"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test coffee script execution
////////////////////////////////////////////////////////////////////////////////
testRequireCoffeeScript : function () {
var test = createTestPackage();
var script = test.require("coffee-test");
assertTrue(script.hasOwnProperty("coffeeSquare"));
assertEqual("function", typeof script.coffeeSquare);
assertEqual(49, script.coffeeSquare(7));
assertTrue(script.hasOwnProperty("coffeeValue"));
assertEqual("string", typeof script.coffeeValue);
assertEqual("test", script.coffeeValue);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test package loading
////////////////////////////////////////////////////////////////////////////////