Permalink
Browse files

added xpath tests, 7 failures with window disabled

  • Loading branch information...
1 parent ba25c2f commit 3140a49cdff86de3ecd4d6974900ea071741ddc7 @tmpvar committed Jul 7, 2011
Showing with 573 additions and 411 deletions.
  1. +12 −11 test/DOMTestCase.js
  2. +534 −400 test/level3/xpath.js
  3. +27 −0 test/tests.js
View
23 test/DOMTestCase.js
@@ -114,20 +114,21 @@ if (actual.length < minLength) {
}
-exports.assertEqualsList = function(descr, expected, actual) {
-var minLength = expected.length;
-if (actual.length < minLength) {
- minLength = actual.length;
-}
+exports.assertEqualsList = exports.arrayEqual = function(test, expected, actual) {
//
- for(var i = 0; i < minLength; i++) {
- if(expected[i] != actual[i]) {
- assertEquals(descr, expected[i], actual[i]);
- }
+ // if they aren't the same size, they aren't equal
+ test.equal(expected.length, actual.length, "Array lengths are not the same!");
+
+ var minLength = expected.length;
+ if (actual.length < minLength) {
+ minLength = actual.length;
}
+
//
- // if they aren't the same size, they aren't equal
- assertEquals(descr, expected.length, actual.length);
+ for(var i = 0; i < minLength; i++) {
+ test.ok(expected[i] === actual[i], "Arrays not equal!" + expected[i] + ' vs ' + actual[i]);
+ }
+
}
exports.assertInstanceOf = function(descr, type, obj) {
View
934 test/level3/xpath.js
@@ -1,3 +1,8 @@
+var xpath = require('../../lib/jsdom/level3/xpath');
+var level3 = require('../../lib/jsdom/level3/core').dom.level3.core;
+var jsdom = require('../../lib/jsdom');
+var domTestHelper = require('../DOMTestCase');
+
exports.tests = {};
function all1(re, s) {
@@ -279,7 +284,7 @@ exports.testParseLocationShorthand = function(test) {
exports.testParseRoot = function(test) {
var s = new xpath.Stream('/');
test.deepEqual(['PathExpr', ['Root']], xpath.parse(s, astFactory));
- test.done();
+ test.done();
};
exports.testEvaluateNumber = function(test) {
@@ -442,7 +447,7 @@ exports.testDescendantOrSelfChild = function(test) {
.map(function(n) {return n.nodeName;})
.join(' ').toLowerCase();
test.deepEqual('br p del ins font', nodeNames);
- test.done();
+ test.done();
};
function testDescendantDfsAndSelfBase(test, andSelf) {
@@ -885,114 +890,146 @@ exports.testAttributeNodePredicate = function(test) {
test.deepEqual(
xpath.stringifyObject({nodes:[child22], pos:[[1]],lasts:[[1]]}),
xpath.stringifyObject(result));
- test.done();
+ test.done();
};
// The following test cases are taken from the NIST XSLT/XPath test suite.
// http://web.archive.org/web/20041019015748/http://xw2k.sdct.itl.nist.gov/xml/page5.html
// Only test cases applicable to XPath are included.
-exports.tests.NIST_coreFunction001 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring", "correct substring",
- xpath.evaluate("substring(substring('internalexternalcorrect substring',9),9)", document, document));
+exports.tests.NIST_coreFunction001 = function(test) {
+ var document = new level3.Document();
+ test.equal("correct substring",
+ xpath.evaluate("substring(substring('internalexternalcorrect substring',9),9)", document, document), "correct substring");
+
+ test.done();
};
-exports.tests.NIST_coreFunction002 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring", "correct substring",
- xpath.evaluate("substring(substring('internalexternalcorrect substring',9,25),9,17)", document, document));
+exports.tests.NIST_coreFunction002 = function(test) {
+ var document = new level3.Document();
+ test.equal("correct substring",
+ xpath.evaluate("substring(substring('internalexternalcorrect substring',9,25),9,17)", document, document), "correct substring");
+
+ test.done();
};
-exports.tests.NIST_coreFunction003 = function() {
- var document = getImplementation().createDocument();
- assertEquals("concatenated string", "A New Concatenated String",
+exports.tests.NIST_coreFunction003 = function(test) {
+ var document = new level3.Document();
+ test.equal("A New Concatenated String",
xpath.evaluate("concat(concat('A ','N','e'),'w ','Concatenated String')", document, document));
+ test.done()
};
-exports.tests.NIST_coreFunction004 = function() {
- var document = getImplementation().createDocument();
- assertEquals("unchanged string", "Unchanged String",
+exports.tests.NIST_coreFunction004 = function(test) {
+ var document = new level3.Document();
+ test.equal("Unchanged String",
xpath.evaluate("string(string('Unchanged String'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction005 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring after", "Correct Substring After",
+exports.tests.NIST_coreFunction005 = function(test) {
+ var document = new level3.Document();
+ test.equal("Correct Substring After",
xpath.evaluate("substring-after(substring-after('wrongnogoodCorrect Substring After','wrong'),'nogood')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction006 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring before", "correct substring Before",
+exports.tests.NIST_coreFunction006 = function(test) {
+ var document = new level3.Document();
+ test.equal("correct substring Before",
xpath.evaluate("substring-before(substring-before('correct substring Beforenogoodwrong','wrong'),'nogood')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction007 = function() {
- var document = getImplementation().createDocument();
- assertEquals("new string", "new string",
+exports.tests.NIST_coreFunction007 = function(test) {
+ var document = new level3.Document();
+ test.equal("new string",
xpath.evaluate("translate(translate('old string','old','123'),'123','new')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction008 = function() {
- var document = getImplementation().createDocument();
- assertEquals("new string", "new string",
+exports.tests.NIST_coreFunction008 = function(test) {
+ var document = new level3.Document();
+ test.equal("new string",
xpath.evaluate("translate('old string',translate('123','123','old'),'new')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction009 = function() {
- var document = getImplementation().createDocument();
- assertEquals("new string", "new string",
+exports.tests.NIST_coreFunction009 = function(test) {
+ var document = new level3.Document();
+ test.equal("new string",
xpath.evaluate("translate(translate('old string','old string','old string'),translate('123','123','old'),translate('123','123','new'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction010 = function() {
- var document = getImplementation().createDocument();
- assertEquals("new string", "new string",
+exports.tests.NIST_coreFunction010 = function(test) {
+ var document = new level3.Document();
+ test.equal("new string",
xpath.evaluate("translate(translate('old string','old string','old string'),translate('123','123','old'),translate('123','123','new'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction011 = function() {
- var document = getImplementation().createDocument();
- assertEquals("a new concatenated string", "A New Concatenated String",
+exports.tests.NIST_coreFunction011 = function(test) {
+ var document = new level3.Document();
+ test.equal("A New Concatenated String",
xpath.evaluate("concat('A New ',concat('Conca','tena','ted '),'String')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction012 = function() {
- var document = getImplementation().createDocument();
- assertEquals("a new concatenated string", "A New Concatenated String",
+exports.tests.NIST_coreFunction012 = function(test) {
+ var document = new level3.Document();
+ test.equal("A New Concatenated String",
xpath.evaluate("concat('A New ','Concatenated ',concat('St','ri','ng'))", document, document));
+ test.done();
};
-exports.tests.NIST_coreFunction013 = function() {
- var document = getImplementation().createDocument();
- assertEquals("a new concatnated string", "A New Concatenated String",
+exports.tests.NIST_coreFunction013 = function(test) {
+ var document = new level3.Document();
+ test.equal("A New Concatenated String",
xpath.evaluate("concat(concat('A ','Ne','w '),concat('Conca','tena','ted '),concat('St','ri','ng'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction014 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring after", "Correct Substring After",
+exports.tests.NIST_coreFunction014 = function(test) {
+ var document = new level3.Document();
+ test.equal("Correct Substring After",
xpath.evaluate("substring-after('wrongCorrect Substring After',substring-after('nogoodstringwrong','nogoodstring'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction015 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring after", "Correct Substring After",
+exports.tests.NIST_coreFunction015 = function(test) {
+ var document = new level3.Document();
+ test.equal("Correct Substring After",
xpath.evaluate("substring-after(substring-after('nogoodwrongCorrect Substring After','nogood'),substring-after('nogoodstringwrong','nogoodstring'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction016 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring before", "Correct Substring Before",
+exports.tests.NIST_coreFunction016 = function(test) {
+ var document = new level3.Document();
+ test.equal("Correct Substring Before",
xpath.evaluate("substring-before('Correct Substring Beforewrong',substring-before('wrongnogood','nogood'))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction017 = function() {
- var document = getImplementation().createDocument();
- assertEquals("correct substring before", "Correct Substring Before",
+exports.tests.NIST_coreFunction017 = function(test) {
+ var document = new level3.Document();
+ test.equal("Correct Substring Before",
xpath.evaluate("substring-before(substring-before('Correct Substring Beforewrongcut here','cut here'),substring-before('wrongnogood','nogood'))", document, document));
+
+ test.done();
};
// coreFunction018 thru coreFunction035 are omitted because they test XPath
@@ -1002,135 +1039,135 @@ exports.tests.NIST_coreFunction017 = function() {
// some non-standard mechanism for setting variables.
//
//
-// exports.tests.NIST_coreFunction018 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction018 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "String From Variable"
-// assertEquals("string from variable", "String From Variable",
+// test.equal("String From Variable",
// xpath.evaluate("string($variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction019 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction019 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "String "
-// assertEquals("string from variable", "String From Variable",
+// test.equal("String From Variable",
// xpath.evaluate("concat($variable1,'From ','Variable')", document, document));
// };
//
-// exports.tests.NIST_coreFunction020 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction020 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "From "
-// assertEquals("string from variable", "String From Variable",
+// test.equal("String From Variable",
// xpath.evaluate("concat('String ',$variable1,'Variable')", document, document));
// };
//
-// exports.tests.NIST_coreFunction021 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction021 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "Variable"
-// assertEquals("string from variable", "String From Variable",
+// test.equal("String From Variable",
// xpath.evaluate("concat('String ','From ',$variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction022 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction022 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "String "
// // set $variable2 = "From "
// // set $variable3 = "Variable"
-// assertEquals("string from variable", "String From Variable",
+// test.equal("String From Variable",
// xpath.evaluate("concat($variable1,$variable2,$variable3)", document, document));
// };
//
-// exports.tests.NIST_coreFunction023 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction023 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "substring-before with variablecut this"
-// assertEquals("substring-before with variable", "substring-before with variable",
+// test.equal("substring-before with variable",
// xpath.evaluate("substring-before($variable1,'cut this')", document, document));
// };
//
-// exports.tests.NIST_coreFunction024 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction024 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut this"
-// assertEquals("substring-before with variable", "substring-before with variable",
+// test.equal("substring-before with variable",
// xpath.evaluate("substring-before('substring-before with variablecut this',$variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction025 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction025 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "substring before with variablecut this"
// // set $variable2 = "cut this"
-// assertEquals("substring before with variable", "substring before with variable",
+// test.equal("substring before with variable",
// xpath.evaluate("substring-before($variable1,$variable2)", document, document));
// };
//
-// exports.tests.NIST_coreFunction026 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction026 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut thissubstring-after with variable"
-// assertEquals("substring-after with variable", "substring-after with variable",
+// test.equal("substring-after with variable",
// xpath.evaluate("substring-after($variable1,'cut this')", document, document));
// };
//
-// exports.tests.NIST_coreFunction027 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction027 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut this"
-// assertEquals("substring after with variable", "substring after with variable",
+// test.equal("substring after with variable",
// xpath.evaluate("substring-after('cut thissubstring after with variable',$variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction028 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction028 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut thissubstring-after with variable"
// // set $variable2 = "cut this"
-// assertEquals("substring-after with variable", "substring-after with variable",
+// test.equal("substring-after with variable",
// xpath.evaluate("substring-after($variable1,$variable2)", document, document));
// };
//
-// exports.tests.NIST_coreFunction029 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction029 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut thissubstring with variable"
-// assertEquals("substring with variable", "substring with variable",
+// test.equal("substring with variable",
// xpath.evaluate("substring($variable1,9)", document, document));
// };
//
-// exports.tests.NIST_coreFunction030 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction030 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "cut thissubstring with variable"
-// assertEquals("substring with variable", "substring with variable",
+// test.equal("substring with variable",
// xpath.evaluate("substring($variable1,9,23)", document, document));
// };
//
-// exports.tests.NIST_coreFunction031 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction031 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "should return the value 26"
-// assertEquals("length 26", 26,
+// test.equal(26,
// xpath.evaluate("string-length($variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction032 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction032 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "translate 1234 variable"
-// assertEquals("translate with variable", "translate with variable",
+// test.equal("translate with variable",
// xpath.evaluate("translate($variable1,'1234','with')", document, document));
// };
//
-// exports.tests.NIST_coreFunction033 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction033 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "1234"
-// assertEquals("translate with variable", "translate with variable",
+// test.equal("translate with variable",
// xpath.evaluate("translate('translate 1234 variable',$variable1,'with')", document, document));
// };
//
-// exports.tests.NIST_coreFunction034 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction034 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "with"
-// assertEquals("translate with variable", "translate with variable",
+// test.equal("translate with variable",
// xpath.evaluate("translate('translate 1234 variable','1234',$variable1)", document, document));
// };
//
-// exports.tests.NIST_coreFunction035 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction035 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "translate 1234 variable"
// // set $variable2 = "1234"
// // set $variable3 = "with"
-// assertEquals("translate with variable", "translate with variable",
+// test.equal("translate with variable",
// xpath.evaluate("translate($variable1,$variable2,$variable3)", document, document));
// };
@@ -1140,179 +1177,222 @@ exports.tests.NIST_coreFunction017 = function() {
// with coreFunction018 thru coreFunction035.
-exports.tests.NIST_coreFunction060 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-2", -2,
+exports.tests.NIST_coreFunction060 = function(test) {
+ var document = new level3.Document();
+ test.equal(-2,
xpath.evaluate("floor(-1.99999)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction061 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-2", -2,
+exports.tests.NIST_coreFunction061 = function(test) {
+ var document = new level3.Document();
+ test.equal(-2,
xpath.evaluate("floor(-1.0001)", document, document));
+
+ test.done();
};
// coreFunction062 is omitted because it tests XPath variables, as above.
-// exports.tests.NIST_coreFunction062 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction062 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "3.1"
-// assertEquals("3", 3,
+// test.equal(3,
// xpath.evaluate("floor($variable1)", document, document));
// };
// coreFunction063 is omitted because it tests XSLT parameters, as above.
-exports.tests.NIST_coreFunction064 = function() {
- var document = getImplementation().createDocument();
- assertEquals("2", 2,
+exports.tests.NIST_coreFunction064 = function(test) {
+ var document = new level3.Document();
+ test.equal(2,
xpath.evaluate("floor(ceiling(1.2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction065 = function() {
- var document = getImplementation().createDocument();
- assertEquals("1", 1,
+exports.tests.NIST_coreFunction065 = function(test) {
+ var document = new level3.Document();
+ test.equal(1,
xpath.evaluate("floor(round(1.2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction066 = function() {
- var document = getImplementation().createDocument();
- assertEquals("1", 1,
+exports.tests.NIST_coreFunction066 = function(test) {
+ var document = new level3.Document();
+ test.equal(1,
xpath.evaluate("floor(floor(1.2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction067 = function() {
- var document = getImplementation().createDocument();
- assertEquals("1", 1,
+exports.tests.NIST_coreFunction067 = function(test) {
+ var document = new level3.Document();
+ test.equal(1,
xpath.evaluate("floor((((((2*10)-4)+9) div 5) mod 2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction068 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-1", -1,
+exports.tests.NIST_coreFunction068 = function(test) {
+ var document = new level3.Document();
+ test.equal(-1,
xpath.evaluate("ceiling(-1.0001)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction069 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-1", -1,
+exports.tests.NIST_coreFunction069 = function(test) {
+ var document = new level3.Document();
+ test.equal(-1,
xpath.evaluate("ceiling(-1.9999)", document, document));
+
+ test.done();
};
// coreFunction070 is omitted because it tests XPath variables, as above.
//
-// exports.tests.NIST_coreFunction070 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction070 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "2.5"
-// assertEquals("3", 3,
+// test.equal(3,
// xpath.evaluate("ceiling($variable1)", document, document));
// };
-exports.tests.NIST_coreFunction071 = function() {
- var document = getImplementation().createDocument();
- assertEquals("2", 2,
+exports.tests.NIST_coreFunction071 = function(test) {
+ var document = new level3.Document();
+ test.equal(2,
xpath.evaluate("ceiling(floor(2.2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction072 = function() {
- var document = getImplementation().createDocument();
- assertEquals("4", 4,
+exports.tests.NIST_coreFunction072 = function(test) {
+ var document = new level3.Document();
+ test.equal(4,
xpath.evaluate("ceiling(ceiling(3.2))", document, document));
+
+ test.done();
};
// coreFunction073 is omitted because it tests XSLT parameters, as above.
-exports.tests.NIST_coreFunction074 = function() {
- var document = getImplementation().createDocument();
- assertEquals("3", 3,
+exports.tests.NIST_coreFunction074 = function(test) {
+ var document = new level3.Document();
+ test.equal(3,
xpath.evaluate("ceiling((((((2*10)-4)+9) div 5) div 2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction075 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-2", -2,
+exports.tests.NIST_coreFunction075 = function(test) {
+ var document = new level3.Document();
+ test.equal(-2,
xpath.evaluate("round(-1.9999)", document, document));
+
+ test.done();
};
// coreFunction076 is omitted because it tests XPath variables, as above.
//
-// exports.tests.NIST_coreFunction076 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_coreFunction076 = function(test) {
+// var document = new level3.Document();
// // set $variable1 = "2.3"
-// assertEquals("2", 2
+// test.equal(2
// xpath.evaluate("round($variable1)", document, document));
// };
// coreFunction077 is omitted because it tests XSLT parameters, as above.
-exports.tests.NIST_coreFunction078 = function() {
- var document = getImplementation().createDocument();
- assertEquals("4", 4,
+exports.tests.NIST_coreFunction078 = function(test) {
+ var document = new level3.Document();
+ test.equal(4,
xpath.evaluate("round(ceiling(3.2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction079 = function() {
- var document = getImplementation().createDocument();
- assertEquals("3", 3,
+exports.tests.NIST_coreFunction079 = function(test) {
+ var document = new level3.Document();
+ test.equal(3,
xpath.evaluate("round((((((2*10)-4)+9) div 5) div 2))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction080 = function() {
- var document = getImplementation().createDocument();
- assertNaN("NaN", xpath.evaluate("round(NaN)", document, document));
+exports.tests.NIST_coreFunction080 = function(test) {
+ var document = new level3.Document();
+ test.ok(isNaN(xpath.evaluate("round(NaN)", document, document)));
+
+ test.done();
};
-exports.tests.NIST_coreFunction081 = function() {
- var document = getImplementation().createDocument();
- assertEquals("0", 0,
+exports.tests.NIST_coreFunction081 = function(test) {
+ var document = new level3.Document();
+ test.equal(0,
xpath.evaluate("round(-0)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction082 = function() {
- var document = getImplementation().createDocument();
- assertEquals("0", 0,
+exports.tests.NIST_coreFunction082 = function(test) {
+ var document = new level3.Document();
+ test.equal(0,
xpath.evaluate("round(-0.25)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction083 = function() {
- var document = getImplementation().createDocument();
- assertEquals("2", 2,
+exports.tests.NIST_coreFunction083 = function(test) {
+ var document = new level3.Document();
+ test.equal(2,
xpath.evaluate("round(round(2.3))", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction084 = function() {
- var document = getImplementation().createDocument();
- assertEquals("infinity", Number.POSITIVE_INFINITY,
+exports.tests.NIST_coreFunction084 = function(test) {
+ var document = new level3.Document();
+ test.equal(Number.POSITIVE_INFINITY,
xpath.evaluate("round(2.3 div 0)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction085 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-infinity", Number.NEGATIVE_INFINITY,
+exports.tests.NIST_coreFunction085 = function(test) {
+ var document = new level3.Document();
+ test.equal(Number.NEGATIVE_INFINITY,
xpath.evaluate("round(-2.3 div 0)", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction086 = function() {
- var document = getImplementation().createDocument();
- assertEquals("-1.9999", -1.9999,
+exports.tests.NIST_coreFunction086 = function(test) {
+ var document = new level3.Document();
+ test.equal(-1.9999,
xpath.evaluate("number('-1.9999')", document, document));
+
+ test.done();
};
-exports.tests.NIST_coreFunction087 = function() {
- var document = getImplementation().createDocument();
- assertEquals("1.9999", 1.9999,
+exports.tests.NIST_coreFunction087 = function(test) {
+ var document = new level3.Document();
+ test.equal(1.9999,
xpath.evaluate("number('1.9999')", document, document));
+ test.done();
};
-exports.tests.NIST_coreFunction088 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_coreFunction088 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1327,12 +1407,13 @@ exports.tests.NIST_coreFunction088 = function() {
text = document.createTextNode("Incorrect execution!!");
child1.appendChild(text);
- assertEquals("1", 1,
+ test.equal(1,
xpath.evaluate("count(//child1[ancestor::element1])", document, doc));
+ test.done();
};
-exports.tests.NIST_coreFunction089 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_coreFunction089 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1344,8 +1425,9 @@ exports.tests.NIST_coreFunction089 = function() {
text = document.createTextNode("Test executed Successfully!!");
element1.appendChild(text);
- assertArrayEquals("element1", [element1],
+ domTestHelper.arrayEqual(test, [element1],
xpath.evaluate("element1[2]", document, doc).nodes);
+ test.done();
};
@@ -1355,44 +1437,50 @@ exports.tests.NIST_coreFunction089 = function() {
// Some dataManipulation tests test XSLT features that aren't part of XPath,
// so those tests are omitted here.
-exports.tests.NIST_dataManipulation001a = function() {
- var document = getImplementation().createDocument();
- assertEquals("2 > 1", true,
+exports.tests.NIST_dataManipulation001a = function(test) {
+ var document = new level3.Document();
+ test.equal(true,
xpath.evaluate("2 > 1", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation001b = function() {
- var document = getImplementation().createDocument();
- assertEquals("9 mod 3 = 0", true,
+exports.tests.NIST_dataManipulation001b = function(test) {
+ var document = new level3.Document();
+ test.equal(true,
xpath.evaluate("9 mod 3 = 0", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation002a = function() {
- var document = getImplementation().createDocument();
- assertEquals("2 > 3 is false", false,
+exports.tests.NIST_dataManipulation002a = function(test) {
+ var document = new level3.Document();
+ test.equal(false,
xpath.evaluate("2 > 3", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation003 = function() {
- var document = getImplementation().createDocument();
- assertEquals("(((((2*10)-4)+9) div 5) div 2) > 2", true,
+exports.tests.NIST_dataManipulation003 = function(test) {
+ var document = new level3.Document();
+ test.equal(true,
xpath.evaluate("(((((2*10)-4)+9) div 5) div 2) > 2", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation004 = function() {
- var document = getImplementation().createDocument();
- assertEquals("(((((2*10)-4)+9) div 5) div 2) > 4 is false", false,
+exports.tests.NIST_dataManipulation004 = function(test) {
+ var document = new level3.Document();
+ test.equal(false,
xpath.evaluate("(((((2*10)-4)+9) div 5) div 2) > 4", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation007 = function() {
- var document = getImplementation().createDocument();
- assertEquals("(round(3.7) > 3)", true,
+exports.tests.NIST_dataManipulation007 = function(test) {
+ var document = new level3.Document();
+ test.equal(true,
xpath.evaluate("(round(3.7) > 3)", document, document));
+ test.done();
};
-exports.tests.NIST_dataManipulation009 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_dataManipulation009 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1403,12 +1491,13 @@ exports.tests.NIST_dataManipulation009 = function() {
text = document.createTextNode("Incorrect execution!!");
element2.appendChild(text);
- assertArrayEquals("doc/element1", [element1],
+ domTestHelper.arrayEqual(test, [element1],
xpath.evaluate("doc/element1", document, document).nodes);
+ test.done();
};
-exports.tests.NIST_dataManipulation013 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_dataManipulation013 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1428,12 +1517,13 @@ exports.tests.NIST_dataManipulation013 = function() {
text = document.createTextNode("Incorrect execution!!");
element2.appendChild(text);
- assertArrayEquals("doc/element1[last()]", [element1],
+ domTestHelper.arrayEqual(test, [element1],
xpath.evaluate("doc/element1[last()]", document, document).nodes);
+ test.done();
};
-exports.tests.NIST_dataManipulation014 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_dataManipulation014 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1453,12 +1543,13 @@ exports.tests.NIST_dataManipulation014 = function() {
text = document.createTextNode("Incorrect execution!!");
element2.appendChild(text);
- assertArrayEquals("element1", [element1],
+ domTestHelper.arrayEqual(test, [element1],
xpath.evaluate("doc/element1[((((((2*10)-4)+9) div 5) mod 3)+1)]", document, document).nodes);
+ test.done();
};
-exports.tests.NIST_dataManipulation016 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_dataManipulation016 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -1473,14 +1564,14 @@ exports.tests.NIST_dataManipulation016 = function() {
element2.appendChild(child1);
text = document.createTextNode("Incorrect Execution!!");
child1.appendChild(text);
-
- assertArrayEquals("element1", [element1],
+ domTestHelper.arrayEqual(test, [element1],
xpath.evaluate("//child1[ancestor::element1]", document, document).nodes);
+ test.done();
};
-exports.tests.NIST_expression001 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression001 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1496,12 +1587,13 @@ exports.tests.NIST_expression001 = function() {
text = document.createTextNode("child2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1,child2],
+ domTestHelper.arrayEqual(test, [child1,child2],
xpath.evaluate("/doc/sub1/child1|/doc/sub2/child2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression002 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression002 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1517,12 +1609,13 @@ exports.tests.NIST_expression002 = function() {
text = document.createTextNode("child2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1,child2],
+ domTestHelper.arrayEqual(test, [child1,child2],
xpath.evaluate("sub1/child1|/doc/sub2/child2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression003 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression003 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1538,18 +1631,19 @@ exports.tests.NIST_expression003 = function() {
text = document.createTextNode("descendant number 2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1,child2],
+ domTestHelper.arrayEqual(test, [child1,child2],
xpath.evaluate("//child1|//child2", document, doc).nodes);
- assertArrayEquals("sub1", [sub1],
+ domTestHelper.arrayEqual(test, [sub1],
xpath.evaluate("ancestor::sub1|ancestor::sub2", document, child1).nodes);
- assertArrayEquals("sub2", [sub2],
+ domTestHelper.arrayEqual(test, [sub2],
xpath.evaluate("ancestor::sub1|ancestor::sub2", document, child2).nodes);
+ test.done();
};
-exports.tests.NIST_expression004 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression004 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1565,18 +1659,19 @@ exports.tests.NIST_expression004 = function() {
text = document.createTextNode("descendant number 2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1,child2],
+ domTestHelper.arrayEqual(test, [child1,child2],
xpath.evaluate("//child1|//child2", document, doc).nodes);
- assertArrayEquals("sub1", [sub1],
+ domTestHelper.arrayEqual(test, [sub1],
xpath.evaluate("ancestor-or-self::sub1|ancestor-or-self::sub2", document, child1).nodes);
- assertArrayEquals("sub2", [sub2],
+ domTestHelper.arrayEqual(test, [sub2],
xpath.evaluate("ancestor-or-self::sub1|ancestor-or-self::sub2", document, child2).nodes);
+ test.done();
};
-exports.tests.NIST_expression005 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression005 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -1624,18 +1719,19 @@ exports.tests.NIST_expression005 = function() {
bibliography = document.createElement("bibliography");
author3.appendChild(bibliography);
- assertArrayEquals("Carmelo Montanez", [author1],
+ domTestHelper.arrayEqual(test, [author1],
xpath.evaluate("author[name/@real='no']|author[name/@real='yes']", document, book1).nodes);
- assertArrayEquals("empty", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("author[name/@real='no']|author[name/@real='yes']", document, book2).nodes);
- assertArrayEquals("Mary Brady", [author3],
+ domTestHelper.arrayEqual(test, [author3],
xpath.evaluate("author[name/@real='no']|author[name/@real='yes']", document, book3).nodes);
+ test.done();
};
-exports.tests.NIST_expression006 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression006 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
doc.setAttribute("attr1", "attribute 1 ");
doc.setAttribute("attr2", "attribute 2");
@@ -1652,12 +1748,13 @@ exports.tests.NIST_expression006 = function() {
text = document.createTextNode("child number 2");
child2.appendChild(text);
- assertArrayEquals("attributes", [doc.getAttributeNode("attr1"), doc.getAttributeNode("attr2")],
+ domTestHelper.arrayEqual(test, [doc.getAttributeNode("attr1"), doc.getAttributeNode("attr2")],
xpath.evaluate("attribute::attr1|attribute::attr2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression007 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression007 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
doc.setAttribute("attr1", "attribute 1 ");
doc.setAttribute("attr2", "attribute 2");
@@ -1674,12 +1771,13 @@ exports.tests.NIST_expression007 = function() {
text = document.createTextNode("child number 2");
child2.appendChild(text);
- assertArrayEquals("sub1|sub2", [sub1, sub2],
+ domTestHelper.arrayEqual(test, [sub1, sub2],
xpath.evaluate("child::sub1|child::sub2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression008 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression008 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -1727,18 +1825,19 @@ exports.tests.NIST_expression008 = function() {
bibliography = document.createElement("bibliography");
author3.appendChild(bibliography);
- assertArrayEquals("Carmelo Montanez", [author1],
+ domTestHelper.arrayEqual(test, [author1],
xpath.evaluate("author[(name/@real='no' and position()=1)]|author[(name/@real='yes' and position()=last())]", document, book1).nodes);
- assertArrayEquals("empty", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("author[(name/@real='no' and position()=1)]|author[(name/@real='yes' and position()=last())]", document, book2).nodes);
- assertArrayEquals("Mary Brady", [author3],
+ domTestHelper.arrayEqual(test, [author3],
xpath.evaluate("author[(name/@real='no' and position()=1)]|author[(name/@real='yes' and position()=last())]", document, book3).nodes);
+ test.done();
};
-exports.tests.NIST_expression009 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression009 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1754,12 +1853,13 @@ exports.tests.NIST_expression009 = function() {
text = document.createTextNode("descendant number 2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1,child2],
+ domTestHelper.arrayEqual(test, [child1,child2],
xpath.evaluate("descendant::child1|descendant::child2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression010 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression010 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1775,12 +1875,13 @@ exports.tests.NIST_expression010 = function() {
text = document.createTextNode("descendant number 2");
child2.appendChild(text);
- assertArrayEquals("doc", [doc],
+ domTestHelper.arrayEqual(test, [doc],
xpath.evaluate("descendant-or-self::doc|descendant-or-self::doc", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression011 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression011 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -1828,22 +1929,23 @@ exports.tests.NIST_expression011 = function() {
bibliography = document.createElement("bibliography");
author3.appendChild(bibliography);
- assertArrayEquals("Carmelo Montanez", [author1],
+ domTestHelper.arrayEqual(test, [author1],
xpath.evaluate("author[name='Mary Brady']|author[name/@real='no']", document, book1).nodes);
- assertArrayEquals("empty", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("author[name='Mary Brady']|author[name/@real='no']", document, book2).nodes);
- assertArrayEquals("Mary Brady", [author3],
+ domTestHelper.arrayEqual(test, [author3],
xpath.evaluate("author[name='Mary Brady']|author[name/@real='no']", document, book3).nodes);
+ test.done();
};
// expression012 tests XPath variables, amongst other features, and is
// omitted as above for other tests. A modified version that does not test
// variables is included below.
//
-// exports.tests.NIST_expression012 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_expression012 = function(test) {
+// var document = new level3.Document();
// var doc = document.createElement("doc");
// document.appendChild(doc);
// var child1 = document.createElement("child1");
@@ -1860,20 +1962,20 @@ exports.tests.NIST_expression011 = function() {
// child3.appendChild(text);
//
// var result1 = xpath.evaluate("//noChild1", document, doc);
-// assertArrayEquals("empty //noChild1", [], result1.nodes);
+// domTestHelper.arrayEqual(test, [], result1.nodes);
//
// var result2 = xpath.evaluate("//noChild2", document, doc);
-// assertArrayEquals("empty //noChild2", [], result2.nodes);
+// domTestHelper.arrayEqual(test, [], result2.nodes);
//
// // set $var1 = result1.nodes
// // set $var2 = result2.nodes
//
-// assertArrayEquals("empty $var1|$var2", [],
+// domTestHelper.arrayEqual(test, [],
// xpath.evaluate("$var1|$var2", document, docu));
// };
-exports.tests.NIST_expression012_noVariables = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression012_noVariables = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -1889,18 +1991,19 @@ exports.tests.NIST_expression012_noVariables = function() {
text = document.createTextNode("Selection of this child is an error.");
child3.appendChild(text);
- assertArrayEquals("empty //noChild1", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("//noChild1", document, doc).nodes);
- assertArrayEquals("empty //noChild2", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("//noChild2", document, doc).nodes);
- assertArrayEquals("empty //noChild1|//noChild2", [],
+ domTestHelper.arrayEqual(test, [],
xpath.evaluate("//noChild1|//noChild2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression013 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression013 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -1918,18 +2021,19 @@ exports.tests.NIST_expression013 = function() {
text = document.createTextNode("following sibling number 3");
child3.appendChild(text);
- assertArrayEquals("child2", [child2],
+ domTestHelper.arrayEqual(test, [child2],
xpath.evaluate("//child2", document, doc).nodes);
- assertArrayEquals("child1|child3", [child1, child3],
+ domTestHelper.arrayEqual(test, [child1, child3],
xpath.evaluate("preceding-sibling::child1|following-sibling::child3", document, child2).nodes);
+ test.done();
};
// expression014 and expression015 are omitted because they test the XSLT
// key() function.
-exports.tests.NIST_expression016 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression016 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -1987,18 +2091,19 @@ exports.tests.NIST_expression016 = function() {
text = document.createTextNode("Five");
chapters.appendChild(text);
- assertArrayEquals("name1", [name1],
+ domTestHelper.arrayEqual(test, [name1],
xpath.evaluate("author/name|author/bibliography/author/name", document, book1).nodes);
- assertArrayEquals("name2", [name2],
+ domTestHelper.arrayEqual(test, [name2],
xpath.evaluate("author/name|author/bibliography/author/name", document, book2).nodes);
- assertArrayEquals("name3|name4", [name3, name4],
+ domTestHelper.arrayEqual(test, [name3, name4],
xpath.evaluate("author/name|author/bibliography/author/name", document, book3).nodes);
+ test.done();
};
-exports.tests.NIST_expression017 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression017 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -2056,18 +2161,19 @@ exports.tests.NIST_expression017 = function() {
text = document.createTextNode("Five");
chapters.appendChild(text);
- assertArrayEquals("name1", [name1],
+ domTestHelper.arrayEqual(test, [name1],
xpath.evaluate("author/name|author/bibliography/author/chapters", document, book1).nodes);
- assertArrayEquals("name2", [name2],
+ domTestHelper.arrayEqual(test, [name2],
xpath.evaluate("author/name|author/bibliography/author/chapters", document, book2).nodes);
- assertArrayEquals("name3|chapters", [name3, chapters],
+ domTestHelper.arrayEqual(test, [name3, chapters],
xpath.evaluate("author/name|author/bibliography/author/chapters", document, book3).nodes);
+ test.done();
};
-exports.tests.NIST_expression018 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression018 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var book1 = document.createElement("book");
@@ -2101,19 +2207,20 @@ exports.tests.NIST_expression018 = function() {
var bibliography2 = document.createElement("bibliography");
author2.appendChild(bibliography2);
- assertArrayEquals("name1", [name1],
+ domTestHelper.arrayEqual(test, [name1],
xpath.evaluate("author/name|author/noElement", document, book1).nodes);
- assertArrayEquals("name2", [name2],
+ domTestHelper.arrayEqual(test, [name2],
xpath.evaluate("author/name|author/noElement", document, book2).nodes);
+ test.done();
};
// expression019 tests XPath variables, amongst other features, and is
// omitted as above for other tests. A modified version that does not test
// variables is included below.
//
-// exports.tests.NIST_expression019 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_expression019 = function(test) {
+// var document = new level3.Document();
// var doc = document.createElement("doc");
// document.appendChild(doc);
// var child1 = document.createElement("child1");
@@ -2130,17 +2237,17 @@ exports.tests.NIST_expression018 = function() {
// child3.appendChild(text);
//
// var result = xpath.evaluate("//child1", document, doc);
-// assertArrayEquals("child1", [child1], result.nodes);
+// domTestHelper.arrayEqual(test, [child1], result.nodes);
//
// // set $var1 = result.nodes
// // set $var2 = result.nodes
//
-// assertArrayEquals("child1", [child1],
+// domTestHelper.arrayEqual(test, [child1],
// xpath.evaluate("$var1|$var2", document, doc));
// };
-exports.tests.NIST_expression019_noVariables = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression019_noVariables = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -2157,14 +2264,15 @@ exports.tests.NIST_expression019_noVariables = function() {
child3.appendChild(text);
var result = xpath.evaluate("//child1", document, doc);
- assertArrayEquals("child1", [child1], result.nodes);
+ domTestHelper.arrayEqual(test, [child1], result.nodes);
- assertArrayEquals("child1", [child1],
+ domTestHelper.arrayEqual(test, [child1],
xpath.evaluate("//child1|//child1", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression020 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression020 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -2180,12 +2288,13 @@ exports.tests.NIST_expression020 = function() {
text = document.createTextNode("child2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1, child2],
+ domTestHelper.arrayEqual(test, [child1, child2],
xpath.evaluate("sub1/child1|sub2/child2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression021 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression021 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var sub1 = document.createElement("sub1");
@@ -2201,18 +2310,19 @@ exports.tests.NIST_expression021 = function() {
text = document.createTextNode("self content number 2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1, child2],
+ domTestHelper.arrayEqual(test, [child1, child2],
xpath.evaluate("//child1|//child2", document, doc).nodes);
- assertArrayEquals("child1", [child1],
+ domTestHelper.arrayEqual(test, [child1],
xpath.evaluate("self::child1|self::child2", document, child1).nodes);
- assertArrayEquals("child2", [child2],
+ domTestHelper.arrayEqual(test, [child2],
xpath.evaluate("self::child1|self::child2", document, child2).nodes);
+ test.done();
};
-exports.tests.NIST_expression022 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression022 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -2224,12 +2334,13 @@ exports.tests.NIST_expression022 = function() {
text = document.createTextNode("2");
child2.appendChild(text);
- assertArrayEquals("child1|child2", [child1, child2],
+ domTestHelper.arrayEqual(test, [child1, child2],
xpath.evaluate("//child1|//child2", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_expression023 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression023 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -2245,8 +2356,9 @@ exports.tests.NIST_expression023 = function() {
text = document.createTextNode("3");
child3.appendChild(text);
- assertArrayEquals("child1|child2|child3", [child1, child2, child3],
+ domTestHelper.arrayEqual(test, [child1, child2, child3],
xpath.evaluate("//child1|//child2|//child3", document, doc).nodes);
+ test.done();
};
// expression024 is omitted because it tests the XSLT key() function.
@@ -2255,8 +2367,8 @@ exports.tests.NIST_expression023 = function() {
// omitted as above for other tests. A modified version that does not test
// variables is included below.
//
-// exports.tests.NIST_expression025 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_expression025 = function(test) {
+// var document = new level3.Document();
// var doc = document.createElement("doc");
// document.appendChild(doc);
// var child1 = document.createElement("child1");
@@ -2272,16 +2384,16 @@ exports.tests.NIST_expression023 = function() {
// child3.appendChild(text);
//
// var result = xpath.evaluate("//child1", document, doc);
-// assertArrayEquals("child1", [child1], result.nodes);
+// domTestHelper.arrayEqual(test, [child1], result.nodes);
//
// // set $var1 = result.nodes
//
-// assertArrayEquals("child1|child2", [child1, child2],
+// domTestHelper.arrayEqual(test, [child1, child2],
// xpath.evaluate("$var1|child::child2", document, doc).nodes);
// };
-exports.tests.NIST_expression025_noVariables = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_expression025_noVariables = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -2297,18 +2409,19 @@ exports.tests.NIST_expression025_noVariables = function() {
child3.appendChild(text);
var result = xpath.evaluate("//child1", document, doc);
- assertArrayEquals("child1", [child1], result.nodes);
+ domTestHelper.arrayEqual(test, [child1], result.nodes);
- assertArrayEquals("child1|child2", [child1, child2],
+ domTestHelper.arrayEqual(test, [child1, child2],
xpath.evaluate("//child1|child::child2", document, doc).nodes);
+ test.done();
};
// expression026 tests XPath variables, so it is omitted as above. There is no
// modified version of this test that does not use variables, because it would
// be redundant with other tests.
//
-// exports.tests.NIST_expression026 = function() {
-// var document = getImplementation().createDocument();
+// exports.tests.NIST_expression026 = function(test) {
+// var document = new level3.Document();
// var doc = document.createElement("doc");
// document.appendChild(doc);
// var child1 = document.createElement("child1");
@@ -2324,82 +2437,92 @@ exports.tests.NIST_expression025_noVariables = function() {
// child3.appendChild(text);
//
// var result1 = xpath.evaluate("//child1", document, doc);
-// assertArrayEquals("child1", [child1], result1.nodes);
+// domTestHelper.arrayEqual(test, [child1], result1.nodes);
//
// var result2 = xpath.evaluate("//child2", document, doc);
-// assertArrayEquals("child2", [child2], result2.nodes);
+// domTestHelper.arrayEqual(test, [child2], result2.nodes);
//
// // set $var1 = result1.nodes
// // set $var2 = result2.nodes
//
-// assertArrayEquals("$var1|$var2", [child1, child2],
+// domTestHelper.arrayEqual(test, [child1, child2],
// xpath.evaluate("$var1|$var2", document, doc).nodes);
// };
-exports.tests.NIST_expression027 = function() {
- var document = getImplementation().createDocument();
- assertTrue("(-0 = 0)", xpath.evaluate("(-0 = 0)", document, document));
+exports.tests.NIST_expression027 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("(-0 = 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression028 = function() {
- var document = getImplementation().createDocument();
- assertFalse("(-0 < 0)", xpath.evaluate("(-0 < 0)", document, document));
+exports.tests.NIST_expression028 = function(test) {
+ var document = new level3.Document();
+ test.equal(false, xpath.evaluate("(-0 < 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression029 = function() {
- var document = getImplementation().createDocument();
- assertFalse("(-0 > 0)", xpath.evaluate("(-0 > 0)", document, document));
+exports.tests.NIST_expression029 = function(test) {
+ var document = new level3.Document();
+ test.equal(false, xpath.evaluate("(-0 > 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression030 = function() {
- var document = getImplementation().createDocument();
- assertTrue("(-0 >= 0)", xpath.evaluate("(-0 >= 0)", document, document));
+exports.tests.NIST_expression030 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("(-0 >= 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression031 = function() {
- var document = getImplementation().createDocument();
- assertTrue("(-0 <= 0)", xpath.evaluate("(-0 <= 0)", document, document));
+exports.tests.NIST_expression031 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("(-0 <= 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression032 = function() {
- var document = getImplementation().createDocument();
- assertFalse("(-0 != 0)", xpath.evaluate("(-0 != 0)", document, document));
+exports.tests.NIST_expression032 = function(test) {
+ var document = new level3.Document();
+ test.equal(false, xpath.evaluate("(-0 != 0)", document, document));
+ test.done();
};
-exports.tests.NIST_expression033 = function() {
- var document = getImplementation().createDocument();
- assertTrue("2.1 > 2.0", xpath.evaluate("2.1 > 2.0", document, document));
- assertFalse("2.1 < 2.0", xpath.evaluate("2.1 < 2.0", document, document));
- assertFalse("2.1 = 2.0", xpath.evaluate("2.1 = 2.0", document, document));
- assertFalse("2.1 > NaN", xpath.evaluate("2.1 > NaN", document, document));
+exports.tests.NIST_expression033 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("2.1 > 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.1 < 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.1 = 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.1 > NaN", document, document));
+ test.done();
};
-exports.tests.NIST_expression034 = function() {
- var document = getImplementation().createDocument();
- assertTrue("2.0 < 2.1", xpath.evaluate("2.0 < 2.1", document, document));
- assertFalse("2.0 > 2.1", xpath.evaluate("2.0 > 2.1", document, document));
- assertFalse("2.0 = 2.1", xpath.evaluate("2.0 = 2.1", document, document));
- assertFalse("2.0 < NaN", xpath.evaluate("2.0 < NaN", document, document));
+exports.tests.NIST_expression034 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("2.0 < 2.1", document, document));
+ test.equal(false, xpath.evaluate("2.0 > 2.1", document, document));
+ test.equal(false, xpath.evaluate("2.0 = 2.1", document, document));
+ test.equal(false, xpath.evaluate("2.0 < NaN", document, document));
+ test.done();
};
-exports.tests.NIST_expression035 = function() {
- var document = getImplementation().createDocument();
- assertTrue("2.0 <= 2.0", xpath.evaluate("2.0 <= 2.0", document, document));
- assertFalse("2.0 > 2.0", xpath.evaluate("2.0 > 2.0", document, document));
- assertTrue("2.0 = 2.0", xpath.evaluate("2.0 = 2.0", document, document));
- assertFalse("2.0 <= NaN", xpath.evaluate("2.0 <= NaN", document, document));
+exports.tests.NIST_expression035 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("2.0 <= 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.0 > 2.0", document, document));
+ test.equal(true, xpath.evaluate("2.0 = 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.0 <= NaN", document, document));
+ test.done();
};
-exports.tests.NIST_expression036 = function() {
- var document = getImplementation().createDocument();
- assertTrue("2.0 >= 2.0", xpath.evaluate("2.0 >= 2.0", document, document));
- assertFalse("2.0 < 2.0", xpath.evaluate("2.0 < 2.0", document, document));
- assertTrue("2.0 = 2.0", xpath.evaluate("2.0 = 2.0", document, document));
- assertFalse("2.0 <= NaN", xpath.evaluate("2.0 <= NaN", document, document));
+exports.tests.NIST_expression036 = function(test) {
+ var document = new level3.Document();
+ test.equal(true, xpath.evaluate("2.0 >= 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.0 < 2.0", document, document));
+ test.equal(true, xpath.evaluate("2.0 = 2.0", document, document));
+ test.equal(false, xpath.evaluate("2.0 <= NaN", document, document));
+ test.done();
};
-exports.tests.NIST_locationPath001 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath001 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var child1 = document.createElement("child1");
@@ -2409,12 +2532,13 @@ exports.tests.NIST_locationPath001 = function() {
var child2 = document.createElement("child2");
child1.appendChild(child2);
- assertArrayEquals("child1", [child1],
+ domTestHelper.arrayEqual(test, [child1],
xpath.evaluate("child1[child::child2]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath002 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath002 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -2441,12 +2565,13 @@ exports.tests.NIST_locationPath002 = function() {
text = document.createTextNode("Text from child2 of second element (corect execution!!)");
child2b.appendChild(text);
- assertArrayEquals("child2", [child2b],
+ domTestHelper.arrayEqual(test, [child2b],
xpath.evaluate("//child2[ancestor::element2]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath003 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath003 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -2473,12 +2598,13 @@ exports.tests.NIST_locationPath003 = function() {
text = document.createTextNode("Text from child2 of second element (corect execution!!)");
child2b.appendChild(text);
- assertArrayEquals("child2", [child2b],
+ domTestHelper.arrayEqual(test, [child2b],
xpath.evaluate("//child2[ancestor-or-self::element2]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath004 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath004 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -2506,12 +2632,13 @@ exports.tests.NIST_locationPath004 = function() {
text = document.createTextNode("Text from child2 of second element (corect execution!!)");
child2b.appendChild(text);
- assertArrayEquals("child2", [child2b],
+ domTestHelper.arrayEqual(test, [child2b],
xpath.evaluate("//child2[attribute::attr1]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath005 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath005 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1a = document.createElement("element1");
@@ -2531,12 +2658,13 @@ exports.tests.NIST_locationPath005 = function() {
text = document.createTextNode("Text from child1 of second element");
child1.appendChild(text);
- assertArrayEquals("element1", [element1a],
+ domTestHelper.arrayEqual(test, [element1a],
xpath.evaluate("element1[descendant-or-self::child2]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath006 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath006 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1 = document.createElement("element1");
@@ -2562,12 +2690,13 @@ exports.tests.NIST_locationPath006 = function() {
text = document.createTextNode("Wrong node selected!!");
child1c.appendChild(text);
- assertArrayEquals("child1", [child1a],
+ domTestHelper.arrayEqual(test, [child1a],
xpath.evaluate("//child1[parent::element1]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath007 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath007 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1a = document.createElement("element1");
@@ -2583,12 +2712,13 @@ exports.tests.NIST_locationPath007 = function() {
text = document.createTextNode("Wrong node selected!!");
element1c.appendChild(text);
- assertArrayEquals("element1", [element1b],
+ domTestHelper.arrayEqual(test, [element1b],
xpath.evaluate("element1[(((((2*10)-4)+9) div 5) mod 3 )]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath008 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath008 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1a = document.createElement("element1");
@@ -2604,12 +2734,13 @@ exports.tests.NIST_locationPath008 = function() {
text = document.createTextNode("Wrong node selected!!");
element1c.appendChild(text);
- assertArrayEquals("element1", [element1b],
+ domTestHelper.arrayEqual(test, [element1b],
xpath.evaluate("element1[(((((2*10)-4)+9) div 5) mod floor(3))]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath009 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath009 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1a = document.createElement("element1");
@@ -2625,12 +2756,13 @@ exports.tests.NIST_locationPath009 = function() {
text = document.createTextNode("Wrong node selected!!");
element1c.appendChild(text);
- assertArrayEquals("element1", [element1b],
+ domTestHelper.arrayEqual(test, [element1b],
xpath.evaluate("element1[floor(2)]", document, doc).nodes);
+ test.done();
};
-exports.tests.NIST_locationPath010 = function() {
- var document = getImplementation().createDocument();
+exports.tests.NIST_locationPath010 = function(test) {
+ var document = new level3.Document();
var doc = document.createElement("doc");
document.appendChild(doc);
var element1a = document.createElement("element1");
@@ -2656,6 +2788,8 @@ exports.tests.NIST_locationPath010 = function() {
text = document.createTextNode("Wrong Node Selected!!");
element1c.appendChild(text);
- assertArrayEquals("child1", [child1c],
+ domTestHelper.arrayEqual(test, [child1c],
xpath.evaluate("doc/element1[(((((2*10)-4)+9) div 5) mod 3)]/child1[last()]", document, document).nodes);
+ test.done();
};
+
View
27 test/tests.js
@@ -0,0 +1,27 @@
+var path = require('path');
+var r = function(suite) {
+ return require(path.join(__dirname, suite))
+}
+
+var fetch = [
+ "level1/core",
+ "level1/html",
+ "level1/svg",
+ "level2/core",
+ "level2/html",
+ "level2/style",
+ "level2/extra",
+
+ //"level3/ls",
+ "level3/xpath",
+ /*"window",*/
+ "jsdom"
+];
+
+module.exports = {};
+
+
+// TODO: filtering
+fetch.forEach(function(k) {
+ module.exports[k] = r(k);
+});

0 comments on commit 3140a49

Please sign in to comment.