Browse Source

Jasmine: Delete remains the old test suite

redux
David Majda 10 years ago
parent
commit
23e04bb4f4
  1. 12
      Makefile
  2. 23
      test/README
  3. 72
      test/helpers.js
  4. 18
      test/index.html
  5. 82
      test/run
  6. 235
      test/vendor/qunit/qunit.css
  7. 1669
      test/vendor/qunit/qunit.js

12
Makefile

@ -2,7 +2,6 @@
SRC_DIR = src
BIN_DIR = bin
TEST_DIR = test
SPEC_DIR = spec
BENCHMARK_DIR = benchmark
EXAMPLES_DIR = examples
@ -36,7 +35,6 @@ JSHINT = jshint
UGLIFYJS = uglifyjs
JASMINE_NODE = jasmine-node
PEGJS = $(BIN_DIR)/pegjs
TEST_RUN = $(TEST_DIR)/run
BENCHMARK_RUN = $(BENCHMARK_DIR)/run
# ===== Variables =====
@ -125,10 +123,6 @@ dist: build
distclean:
rm -rf $(DIST_DIR)
# Run the test suite
test: build
$(TEST_RUN)
# Run the spec suite
spec: build
$(JASMINE_NODE) --verbose $(SPEC_DIR)
@ -141,12 +135,10 @@ benchmark: build
hint: build
$(JSHINT) \
`find $(SRC_DIR) -name '*.js'` \
`find $(TEST_DIR) -name '*.js' -and -not -path '$(TEST_DIR)/vendor/*'` \
$(TEST_RUN) \
`find $(SPEC_DIR) -name '*.js' -and -not -path '$(SPEC_DIR)/vendor/*'` \
$(BENCHMARK_DIR)/*.js \
$(BENCHMARK_RUN) \
$(PEGJS)
.PHONY: test spec benchmark hint parser build clean dist distclean
.SILENT: test spec benchmark hint parser build clean dist distclean
.PHONY: spec benchmark hint parser build clean dist distclean
.SILENT: spec benchmark hint parser build clean dist distclean

23
test/README

@ -1,23 +0,0 @@
PEG.js Test Suite
=================
This is the PEG.js test suite. It ensures PEG.js works correctly. All tests
should always pass on all supported platforms.
Running in a browser
--------------------
1. Open the index.html file in your browser.
2. Watch the test pass (or fail).
Running from a command-line
---------------------------
1. Make sure you have Node.js installed.
2. Run the following command:
./run
3. Watch the tests pass (or fail).

72
test/helpers.js

@ -1,72 +0,0 @@
(function(global) {
var extensions = {
parses: function(parser, input, expected) {
QUnit.deepEqual(parser.parse(input), expected);
},
parsesWithStartRule: function(parser, input, startRule, expected) {
QUnit.deepEqual(parser.parse(input, startRule), expected);
},
doesNotParse: function(parser, input) {
QUnit.raises(function() { parser.parse(input); }, parser.SyntaxError);
},
doesNotParseWithMessage: function(parser, input, message) {
QUnit.raises(
function() { parser.parse(input); },
function(e) {
return e instanceof parser.SyntaxError && e.message === message;
}
);
},
doesNotParseWithDetails: function(parser, input, expected, found, message) {
QUnit.raises(
function() { parser.parse(input); },
function(e) {
var i;
if (!(e instanceof parser.SyntaxError)) { return false; }
if (e.expected.length !== expected.length) { return false; }
for (i = 0; i < e.expected.length; i++) {
if (e.expected[i] !== expected[i]) { return false; }
}
if (e.found !== found) { return false; }
if (e.message !== message) { return false; }
return true;
}
);
},
doesNotParseWithPos: function(parser, input, offset, line, column) {
QUnit.raises(
function() { parser.parse(input); },
function(e) {
return e instanceof parser.SyntaxError
&& e.offset === offset
&& e.line === line
&& e.column === column;
}
);
},
parserParses: function(input, expected) {
QUnit.parses(PEG.parser, input, expected);
},
parserDoesNotParse: function(input) {
QUnit.doesNotParse(PEG.parser, input);
},
parserDoesNotParseWithMessage: function(input, message) {
QUnit.doesNotParseWithMessage(PEG.parser, input, message);
}
};
QUnit.extend(QUnit, extensions);
QUnit.extend(global, extensions);
})(this);

18
test/index.html

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PEG.js Test Suite</title>
<link rel="stylesheet" href="vendor/qunit/qunit.css">
<script src="../lib/peg.js"></script>
<script src="vendor/qunit/qunit.js"></script>
<script src="helpers.js"></script>
</head>
<body>
<h1 id="qunit-header">PEG.js Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
</html>

82
test/run

@ -1,82 +0,0 @@
#!/usr/bin/env node
var util = require("util"),
fs = require("fs"),
PEG = require("../lib/peg"),
QUnit = require("./vendor/qunit/qunit");
var failedAssertions = [];
function bold(s) { return "\u001B[1m" + s + "\u001B[22m"; };
function message(s) { return "\u001B[35m" + s + "\u001B[39m"; };
function ok(s) { return "\u001B[32m" + s + "\u001B[39m"; };
function error(s) { return "\u001B[31m" + s + "\u001B[39m"; };
function indent(s) { return s.replace(/^/gm, " "); }
QUnit.init();
QUnit.config.blocking = true;
QUnit.config.updateRate = 0;
QUnit.moduleStart(function(details) {
util.puts("");
util.puts(bold(details.name));
});
QUnit.testStart(function(details) {
failedAssertions = [];
});
QUnit.testDone(function(details) {
if (details.failed == 0) {
util.puts('✔ ' + details.name);
} else {
util.puts(error('✖ ' + details.name));
util.puts("");
failedAssertions.forEach(function(assertion) {
util.puts(assertion);
});
}
});
QUnit.log(function(details) {
var output = "";
if (details.result) { return; }
if (details.message) {
output += indent("Message: " + message(details.message)) + "\n";
}
if (details.actual && details.expected) {
output += indent("Expected: " + QUnit.jsDump.parse(details.expected)) + "\n";
if (details.actual != details.expected) {
output += indent("Actual: " + QUnit.jsDump.parse(details.actual));
}
}
failedAssertions.push(output);
});
QUnit.done(function(details) {
util.puts("");
if (details.failed > 0) {
util.puts(bold(error("FAILURES: "))
+ details.failed + "/"
+ details.total + " assertions failed ("
+ details.runtime + " ms)"
);
} else {
util.puts(bold(ok('OK: '))
+ details.total + " assertions ("
+ details.runtime + " ms)"
)
}
});
[
"helpers.js"
].forEach(function(file) {
eval("with (QUnit) {" + fs.readFileSync(__dirname + "/" + file, "utf8") + "}");
});
QUnit.start();

235
test/vendor/qunit/qunit.css

@ -1,235 +0,0 @@
/**
* QUnit v1.5.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
* Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-header label {
display: inline-block;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests ol {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
background-color: #fff;
border-left: 26px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
#qunit-testresult .module-name {
font-weight: bold;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}

1669
test/vendor/qunit/qunit.js
File diff suppressed because it is too large
View File

Loading…
Cancel
Save