}
};
+var testCaseList = [];
+
function TestCase(name) {
- jstd.sucker("Not really creating TestCase(" + name + ")");
this.name = name;
this.toString = function() {
return "Fake test case " + name;
}
console.log(prettyPrintEntity_(tests));
};
+
+ testCaseList.push(testCase);
return testCase;
};
+
+// Note: this creates a bunch of global variables intentionally.
+function addGlobalTestSymbols() {
+ globalTestDb = {}; // maps test name -> test function wrapper
+
+ var num_tests = 0;
+ for (var i = 0; i < testCaseList.length; i++) {
+ var tc_class = testCaseList[i];
+ for (var name in tc_class.prototype) {
+ if (name.indexOf('test') == 0 && typeof(tc_class.prototype[name]) == 'function') {
+ if (globalTestDb.hasOwnProperty(name)) {
+ console.log('Duplicated test name: ' + name);
+ } else {
+ globalTestDb[name] = function(name, tc_class) {
+ return function() {
+ var tc = new tc_class;
+ console.log(name);
+ return tc.runTest(name);
+ };
+ }(name, tc_class);
+ eval(name + " = globalTestDb['" + name + "'];");
+ num_tests += 1;
+ }
+ }
+ }
+ }
+ console.log('Loaded ' + num_tests + ' tests in ' +
+ testCaseList.length + ' test cases');
+}
</head>
<body>
<div id='graph'></div>
- This file is really nothing more than all the tests coalesced into a single
+ <p>This file is really nothing more than all the tests coalesced into a single
HTML file. To run a test, open a Javascript console and execute, for
- instance,<br>
- <code>tc = new SimpleDrawingTestCase() ;<br>
- tc.runTest("testDrawSimpleRangePlusOne")</code> (execution method #1, by string) </br>
- <code>tc.runTest(tc.testDrawSimpleRangePlusOne)</code> (execution method #2, by function reference)
+ instance,</p>
+ <code>testDrawSimpleRangePlusOne()</code>
<p>Alternatively you can use query args: <ul>
<li>testCase - for the name of the test case
</body>
<script>
processVariables();
+addGlobalTestSymbols();
</script>
</html>