everqueen 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +163 -0
- data/bin/everqueen +18 -0
- data/config/routes.rb +3 -0
- data/lib/everqueen.rb +66 -0
- data/lib/everqueen/application.rb +47 -0
- data/lib/everqueen/assets/elabs.png +0 -0
- data/lib/everqueen/assets/everqueen.scss.css +370 -0
- data/lib/everqueen/assets/jquery.js +152 -0
- data/lib/everqueen/assets/json2.js +25 -0
- data/lib/everqueen/assets/list.js.coffee +35 -0
- data/lib/everqueen/assets/run.js.coffee.erb +39 -0
- data/lib/everqueen/assets/start.js.coffee +6 -0
- data/lib/everqueen/assets/test_helper.js +3 -0
- data/lib/everqueen/cli.rb +29 -0
- data/lib/everqueen/rails.rb +14 -0
- data/lib/everqueen/runner.rb +151 -0
- data/lib/everqueen/server.rb +19 -0
- data/lib/everqueen/suite.rb +32 -0
- data/lib/everqueen/tasks.rb +10 -0
- data/lib/everqueen/test.rb +44 -0
- data/lib/everqueen/version.rb +3 -0
- data/lib/everqueen/views/_test_error.erb +4 -0
- data/lib/everqueen/views/layout.erb +17 -0
- data/lib/everqueen/views/list.erb +19 -0
- data/lib/everqueen/views/run.erb +20 -0
- data/lib/qunit/History.md +330 -0
- data/lib/qunit/README.md +37 -0
- data/lib/qunit/addons/canvas/README.md +16 -0
- data/lib/qunit/addons/canvas/canvas-test.js +76 -0
- data/lib/qunit/addons/canvas/canvas.html +19 -0
- data/lib/qunit/addons/canvas/qunit-canvas.js +6 -0
- data/lib/qunit/addons/close-enough/README.md +17 -0
- data/lib/qunit/addons/close-enough/close-enough-test.js +37 -0
- data/lib/qunit/addons/close-enough/close-enough.html +18 -0
- data/lib/qunit/addons/close-enough/qunit-close-enough.js +32 -0
- data/lib/qunit/addons/composite/README.md +7 -0
- data/lib/qunit/addons/composite/composite-demo-test.html +33 -0
- data/lib/qunit/addons/composite/composite-test.html +20 -0
- data/lib/qunit/addons/composite/composite-test.js +159 -0
- data/lib/qunit/addons/composite/dummy-qunit-test.html +19 -0
- data/lib/qunit/addons/composite/dummy-same-test.html +19 -0
- data/lib/qunit/addons/composite/index.html +35 -0
- data/lib/qunit/addons/composite/qunit-composite.css +13 -0
- data/lib/qunit/addons/composite/qunit-composite.js +82 -0
- data/lib/qunit/addons/step/README.md +18 -0
- data/lib/qunit/addons/step/qunit-step.js +25 -0
- data/lib/qunit/addons/step/step-test.js +13 -0
- data/lib/qunit/addons/step/step.html +19 -0
- data/lib/qunit/package.json +28 -0
- data/lib/qunit/qunit/qunit.css +226 -0
- data/lib/qunit/qunit/qunit.js +1597 -0
- data/lib/qunit/test/headless.html +24 -0
- data/lib/qunit/test/index.html +21 -0
- data/lib/qunit/test/logs.html +17 -0
- data/lib/qunit/test/logs.js +153 -0
- data/lib/qunit/test/same.js +1432 -0
- data/lib/qunit/test/swarminject.js +9 -0
- data/lib/qunit/test/test.js +524 -0
- data/lib/tasks/everqueen.rake +8 -0
- data/spec/everqueen_spec.rb +52 -0
- data/spec/meta_spec.rb +40 -0
- data/spec/runner_spec.rb +32 -0
- data/spec/spec_helper.rb +49 -0
- data/spec/suite1/public/jquery.js +152 -0
- data/spec/suite1/public/styles.css +3 -0
- data/spec/suite1/test/javascripts/bar_test.js +0 -0
- data/spec/suite1/test/javascripts/coffeescript_test.coffee +7 -0
- data/spec/suite1/test/javascripts/failing_test.js +9 -0
- data/spec/suite1/test/javascripts/foo_test.js +0 -0
- data/spec/suite1/test/javascripts/libs/lucid_test.js +0 -0
- data/spec/suite1/test/javascripts/models/game_test.js +0 -0
- data/spec/suite1/test/javascripts/slow_test.coffee +8 -0
- data/spec/suite1/test/javascripts/test_helper.js +1 -0
- data/spec/suite1/test/javascripts/testing_test.js +9 -0
- data/spec/suite1/test/javascripts/transactions_test.js +10 -0
- data/spec/suite1/test/javascripts/with_helper_test.js +4 -0
- data/spec/suite2/config/everqueen.rb +4 -0
- data/spec/suite2/public_html/foo.js +1 -0
- data/spec/suite2/test/awesome_test.js +7 -0
- data/spec/suite2/test/failing_test.js +4 -0
- data/spec/suite_spec.rb +19 -0
- data/spec/test_spec.rb +21 -0
- metadata +295 -0
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            // load testswarm agent
         | 
| 2 | 
            +
            (function() {
         | 
| 3 | 
            +
                var url = window.location.search;
         | 
| 4 | 
            +
            	url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
         | 
| 5 | 
            +
            	if ( !url || url.indexOf("http") !== 0 ) {
         | 
| 6 | 
            +
            		return;
         | 
| 7 | 
            +
            	}
         | 
| 8 | 
            +
                document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
         | 
| 9 | 
            +
            })();
         | 
| @@ -0,0 +1,524 @@ | |
| 1 | 
            +
            test("module without setup/teardown (default)", function() {
         | 
| 2 | 
            +
            	expect(1);
         | 
| 3 | 
            +
            	ok(true);
         | 
| 4 | 
            +
            });
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            test("expect in test", 3, function() {
         | 
| 7 | 
            +
            	ok(true);
         | 
| 8 | 
            +
            	ok(true);
         | 
| 9 | 
            +
            	ok(true);
         | 
| 10 | 
            +
            });
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            test("expect in test", 1, function() {
         | 
| 13 | 
            +
            	ok(true);
         | 
| 14 | 
            +
            });
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            module("setup test", {
         | 
| 17 | 
            +
            	setup: function() {
         | 
| 18 | 
            +
            		ok(true);
         | 
| 19 | 
            +
            	}
         | 
| 20 | 
            +
            });
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            test("module with setup", function() {
         | 
| 23 | 
            +
            	expect(2);
         | 
| 24 | 
            +
            	ok(true);
         | 
| 25 | 
            +
            });
         | 
| 26 | 
            +
             | 
| 27 | 
            +
             | 
| 28 | 
            +
            test("module with setup, expect in test call", 2, function() {
         | 
| 29 | 
            +
            	ok(true);
         | 
| 30 | 
            +
            });
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            var state;
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            module("setup/teardown test", {
         | 
| 35 | 
            +
            	setup: function() {
         | 
| 36 | 
            +
            		state = true;
         | 
| 37 | 
            +
            		ok(true);
         | 
| 38 | 
            +
            	},
         | 
| 39 | 
            +
            	teardown: function() {
         | 
| 40 | 
            +
            		ok(true);
         | 
| 41 | 
            +
            	}
         | 
| 42 | 
            +
            });
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            test("module with setup/teardown", function() {
         | 
| 45 | 
            +
            	expect(3);
         | 
| 46 | 
            +
            	ok(true);
         | 
| 47 | 
            +
            });
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            module("setup/teardown test 2");
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            test("module without setup/teardown", function() {
         | 
| 52 | 
            +
            	expect(1);
         | 
| 53 | 
            +
            	ok(true);
         | 
| 54 | 
            +
            });
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            if (typeof setTimeout !== 'undefined') {
         | 
| 57 | 
            +
            state = 'fail';
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            module("teardown and stop", {
         | 
| 60 | 
            +
            	teardown: function() {
         | 
| 61 | 
            +
            		equal(state, "done", "Test teardown.");
         | 
| 62 | 
            +
            	}
         | 
| 63 | 
            +
            });
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            test("teardown must be called after test ended", function() {
         | 
| 66 | 
            +
            	expect(1);
         | 
| 67 | 
            +
            	stop();
         | 
| 68 | 
            +
            	setTimeout(function() {
         | 
| 69 | 
            +
            		state = "done";
         | 
| 70 | 
            +
            		start();
         | 
| 71 | 
            +
            	}, 13);
         | 
| 72 | 
            +
            });
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            test("parameter passed to stop increments semaphore n times", function() {
         | 
| 75 | 
            +
            	expect(1);
         | 
| 76 | 
            +
            	stop(3);
         | 
| 77 | 
            +
            	setTimeout(function() {
         | 
| 78 | 
            +
            		state = "not enough starts";
         | 
| 79 | 
            +
            		start(), start();
         | 
| 80 | 
            +
            	}, 13);
         | 
| 81 | 
            +
            	setTimeout(function() {
         | 
| 82 | 
            +
            		state = "done";
         | 
| 83 | 
            +
            		start();
         | 
| 84 | 
            +
            	}, 15);
         | 
| 85 | 
            +
            });
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            test("parameter passed to start decrements semaphore n times", function() {
         | 
| 88 | 
            +
            	expect(1);
         | 
| 89 | 
            +
            	stop(), stop(), stop();
         | 
| 90 | 
            +
            	setTimeout(function() {
         | 
| 91 | 
            +
            		state = "done";
         | 
| 92 | 
            +
            		start(3);
         | 
| 93 | 
            +
            	}, 18);
         | 
| 94 | 
            +
            });
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            module("async setup test", {
         | 
| 97 | 
            +
            	setup: function() {
         | 
| 98 | 
            +
            		stop();
         | 
| 99 | 
            +
            		setTimeout(function(){
         | 
| 100 | 
            +
            			ok(true);
         | 
| 101 | 
            +
            			start();
         | 
| 102 | 
            +
            		}, 500);
         | 
| 103 | 
            +
            	}
         | 
| 104 | 
            +
            });
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            asyncTest("module with async setup", function() {
         | 
| 107 | 
            +
            	expect(2);
         | 
| 108 | 
            +
            	ok(true);
         | 
| 109 | 
            +
            	start();
         | 
| 110 | 
            +
            });
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            module("async teardown test", {
         | 
| 113 | 
            +
            	teardown: function() {
         | 
| 114 | 
            +
            		stop();
         | 
| 115 | 
            +
            		setTimeout(function(){
         | 
| 116 | 
            +
            			ok(true);
         | 
| 117 | 
            +
            			start();
         | 
| 118 | 
            +
            		}, 500);
         | 
| 119 | 
            +
            	}
         | 
| 120 | 
            +
            });
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            asyncTest("module with async teardown", function() {
         | 
| 123 | 
            +
            	expect(2);
         | 
| 124 | 
            +
            	ok(true);
         | 
| 125 | 
            +
            	start();
         | 
| 126 | 
            +
            });
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            module("asyncTest");
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            asyncTest("asyncTest", function() {
         | 
| 131 | 
            +
            	expect(2);
         | 
| 132 | 
            +
            	ok(true);
         | 
| 133 | 
            +
            	setTimeout(function() {
         | 
| 134 | 
            +
            		state = "done";
         | 
| 135 | 
            +
            		ok(true);
         | 
| 136 | 
            +
            		start();
         | 
| 137 | 
            +
            	}, 13);
         | 
| 138 | 
            +
            });
         | 
| 139 | 
            +
             | 
| 140 | 
            +
            asyncTest("asyncTest", 2, function() {
         | 
| 141 | 
            +
            	ok(true);
         | 
| 142 | 
            +
            	setTimeout(function() {
         | 
| 143 | 
            +
            		state = "done";
         | 
| 144 | 
            +
            		ok(true);
         | 
| 145 | 
            +
            		start();
         | 
| 146 | 
            +
            	}, 13);
         | 
| 147 | 
            +
            });
         | 
| 148 | 
            +
             | 
| 149 | 
            +
            test("sync", 2, function() {
         | 
| 150 | 
            +
            	stop();
         | 
| 151 | 
            +
            	setTimeout(function() {
         | 
| 152 | 
            +
            		ok(true);
         | 
| 153 | 
            +
            		start();
         | 
| 154 | 
            +
            	}, 13);
         | 
| 155 | 
            +
            	stop();
         | 
| 156 | 
            +
            	setTimeout(function() {
         | 
| 157 | 
            +
            		ok(true);
         | 
| 158 | 
            +
            		start();
         | 
| 159 | 
            +
            	}, 125);
         | 
| 160 | 
            +
            });
         | 
| 161 | 
            +
             | 
| 162 | 
            +
            test("test synchronous calls to stop", 2, function() {
         | 
| 163 | 
            +
                stop();
         | 
| 164 | 
            +
                setTimeout(function(){
         | 
| 165 | 
            +
                    ok(true, 'first');
         | 
| 166 | 
            +
                    start();
         | 
| 167 | 
            +
                    stop();
         | 
| 168 | 
            +
                    setTimeout(function(){
         | 
| 169 | 
            +
                        ok(true, 'second');
         | 
| 170 | 
            +
                        start();
         | 
| 171 | 
            +
                    }, 150);
         | 
| 172 | 
            +
                }, 150);
         | 
| 173 | 
            +
            });
         | 
| 174 | 
            +
            }
         | 
| 175 | 
            +
             | 
| 176 | 
            +
            module("save scope", {
         | 
| 177 | 
            +
            	setup: function() {
         | 
| 178 | 
            +
            		this.foo = "bar";
         | 
| 179 | 
            +
            	},
         | 
| 180 | 
            +
            	teardown: function() {
         | 
| 181 | 
            +
            		deepEqual(this.foo, "bar");
         | 
| 182 | 
            +
            	}
         | 
| 183 | 
            +
            });
         | 
| 184 | 
            +
            test("scope check", function() {
         | 
| 185 | 
            +
            	expect(2);
         | 
| 186 | 
            +
            	deepEqual(this.foo, "bar");
         | 
| 187 | 
            +
            });
         | 
| 188 | 
            +
             | 
| 189 | 
            +
            module("simple testEnvironment setup", {
         | 
| 190 | 
            +
            	foo: "bar",
         | 
| 191 | 
            +
            	bugid: "#5311" // example of meta-data
         | 
| 192 | 
            +
            });
         | 
| 193 | 
            +
            test("scope check", function() {
         | 
| 194 | 
            +
            	deepEqual(this.foo, "bar");
         | 
| 195 | 
            +
            });
         | 
| 196 | 
            +
            test("modify testEnvironment",function() {
         | 
| 197 | 
            +
            	this.foo="hamster";
         | 
| 198 | 
            +
            });
         | 
| 199 | 
            +
            test("testEnvironment reset for next test",function() {
         | 
| 200 | 
            +
            	deepEqual(this.foo, "bar");
         | 
| 201 | 
            +
            });
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            module("testEnvironment with object", {
         | 
| 204 | 
            +
            	options:{
         | 
| 205 | 
            +
            		recipe:"soup",
         | 
| 206 | 
            +
            		ingredients:["hamster","onions"]
         | 
| 207 | 
            +
            	}
         | 
| 208 | 
            +
            });
         | 
| 209 | 
            +
            test("scope check", function() {
         | 
| 210 | 
            +
            	deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
         | 
| 211 | 
            +
            });
         | 
| 212 | 
            +
            test("modify testEnvironment",function() {
         | 
| 213 | 
            +
            	// since we do a shallow copy, the testEnvironment can be modified
         | 
| 214 | 
            +
            	this.options.ingredients.push("carrots");
         | 
| 215 | 
            +
            });
         | 
| 216 | 
            +
            test("testEnvironment reset for next test",function() {
         | 
| 217 | 
            +
            	deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
         | 
| 218 | 
            +
            });
         | 
| 219 | 
            +
             | 
| 220 | 
            +
             | 
| 221 | 
            +
            module("testEnvironment tests");
         | 
| 222 | 
            +
             | 
| 223 | 
            +
            function makeurl() {
         | 
| 224 | 
            +
            	var testEnv = QUnit.current_testEnvironment;
         | 
| 225 | 
            +
            	var url = testEnv.url || 'http://example.com/search';
         | 
| 226 | 
            +
            	var q   = testEnv.q   || 'a search test';
         | 
| 227 | 
            +
            	return url + '?q='+encodeURIComponent(q);
         | 
| 228 | 
            +
            }
         | 
| 229 | 
            +
             | 
| 230 | 
            +
            test("makeurl working",function() {
         | 
| 231 | 
            +
            	equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
         | 
| 232 | 
            +
            	equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
         | 
| 233 | 
            +
            });
         | 
| 234 | 
            +
             | 
| 235 | 
            +
            module("testEnvironment with makeurl settings", {
         | 
| 236 | 
            +
            	url: 'http://google.com/',
         | 
| 237 | 
            +
            	q: 'another_search_test'
         | 
| 238 | 
            +
            });
         | 
| 239 | 
            +
            test("makeurl working with settings from testEnvironment", function() {
         | 
| 240 | 
            +
            	equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to form the url');
         | 
| 241 | 
            +
            });
         | 
| 242 | 
            +
            test("each test can extend the module testEnvironment", {
         | 
| 243 | 
            +
            	q:'hamstersoup'
         | 
| 244 | 
            +
            }, function() {
         | 
| 245 | 
            +
            	equal( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test');
         | 
| 246 | 
            +
            });
         | 
| 247 | 
            +
             | 
| 248 | 
            +
            module("jsDump");
         | 
| 249 | 
            +
            test("jsDump output", function() {
         | 
| 250 | 
            +
            	equal( QUnit.jsDump.parse([1, 2]), "[\n  1,\n  2\n]" );
         | 
| 251 | 
            +
            	equal( QUnit.jsDump.parse({top: 5, left: 0}), "{\n  \"top\": 5,\n  \"left\": 0\n}" );
         | 
| 252 | 
            +
            	if (typeof document !== 'undefined' && document.getElementById("qunit-header")) {
         | 
| 253 | 
            +
            		equal( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" );
         | 
| 254 | 
            +
            		equal( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n  <h1 id=\"qunit-header\"></h1>\n]" );
         | 
| 255 | 
            +
            	}
         | 
| 256 | 
            +
            });
         | 
| 257 | 
            +
             | 
| 258 | 
            +
            module("assertions");
         | 
| 259 | 
            +
            test("raises",function() {
         | 
| 260 | 
            +
            	function CustomError( message ) {
         | 
| 261 | 
            +
            		this.message = message;
         | 
| 262 | 
            +
            	}
         | 
| 263 | 
            +
             | 
| 264 | 
            +
            	CustomError.prototype.toString = function() {
         | 
| 265 | 
            +
            		return this.message;
         | 
| 266 | 
            +
            	};
         | 
| 267 | 
            +
             | 
| 268 | 
            +
            	raises(
         | 
| 269 | 
            +
            		function() {
         | 
| 270 | 
            +
            			throw "error"
         | 
| 271 | 
            +
            		}
         | 
| 272 | 
            +
            	);
         | 
| 273 | 
            +
             | 
| 274 | 
            +
            	raises(
         | 
| 275 | 
            +
            		function() {
         | 
| 276 | 
            +
            			throw "error"
         | 
| 277 | 
            +
            		},
         | 
| 278 | 
            +
            		'raises with just a message, no expected'
         | 
| 279 | 
            +
            	);
         | 
| 280 | 
            +
             | 
| 281 | 
            +
            	raises(
         | 
| 282 | 
            +
            		function() {
         | 
| 283 | 
            +
            			throw new CustomError();
         | 
| 284 | 
            +
            		},
         | 
| 285 | 
            +
            		CustomError,
         | 
| 286 | 
            +
            		'raised error is an instance of CustomError'
         | 
| 287 | 
            +
            	);
         | 
| 288 | 
            +
             | 
| 289 | 
            +
            	raises(
         | 
| 290 | 
            +
            		function() {
         | 
| 291 | 
            +
            			throw new CustomError("some error description");
         | 
| 292 | 
            +
            		},
         | 
| 293 | 
            +
            		/description/,
         | 
| 294 | 
            +
            		"raised error message contains 'description'"
         | 
| 295 | 
            +
            	);
         | 
| 296 | 
            +
             | 
| 297 | 
            +
            	raises(
         | 
| 298 | 
            +
            		function() {
         | 
| 299 | 
            +
            			throw new CustomError("some error description");
         | 
| 300 | 
            +
            		},
         | 
| 301 | 
            +
            		function( err ) {
         | 
| 302 | 
            +
            			if ( (err instanceof CustomError) && /description/.test(err) ) {
         | 
| 303 | 
            +
            				return true;
         | 
| 304 | 
            +
            			}
         | 
| 305 | 
            +
            		},
         | 
| 306 | 
            +
            		"custom validation function"
         | 
| 307 | 
            +
            	);
         | 
| 308 | 
            +
             | 
| 309 | 
            +
            });
         | 
| 310 | 
            +
             | 
| 311 | 
            +
            if (typeof document !== "undefined") {
         | 
| 312 | 
            +
             | 
| 313 | 
            +
            module("fixture");
         | 
| 314 | 
            +
            test("setup", function() {
         | 
| 315 | 
            +
            	document.getElementById("qunit-fixture").innerHTML = "foobar";
         | 
| 316 | 
            +
            });
         | 
| 317 | 
            +
            test("basics", function() {
         | 
| 318 | 
            +
            	equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
         | 
| 319 | 
            +
            });
         | 
| 320 | 
            +
             | 
| 321 | 
            +
            }
         | 
| 322 | 
            +
             | 
| 323 | 
            +
            module("custom assertions");
         | 
| 324 | 
            +
            (function() {
         | 
| 325 | 
            +
            	function mod2(value, expected, message) {
         | 
| 326 | 
            +
            		var actual = value % 2;
         | 
| 327 | 
            +
            		QUnit.push(actual == expected, actual, expected, message);
         | 
| 328 | 
            +
            	}
         | 
| 329 | 
            +
            	test("mod2", function() {
         | 
| 330 | 
            +
            		mod2(2, 0, "2 % 2 == 0");
         | 
| 331 | 
            +
            		mod2(3, 1, "3 % 2 == 1");
         | 
| 332 | 
            +
            	})
         | 
| 333 | 
            +
            })();
         | 
| 334 | 
            +
             | 
| 335 | 
            +
             | 
| 336 | 
            +
            module("recursions");
         | 
| 337 | 
            +
             | 
| 338 | 
            +
            function Wrap(x) {
         | 
| 339 | 
            +
                this.wrap = x;
         | 
| 340 | 
            +
                if (x == undefined)  this.first = true;
         | 
| 341 | 
            +
            }
         | 
| 342 | 
            +
             | 
| 343 | 
            +
            function chainwrap(depth, first, prev) {
         | 
| 344 | 
            +
                depth = depth || 0;
         | 
| 345 | 
            +
                var last = prev || new Wrap();
         | 
| 346 | 
            +
                first = first || last;
         | 
| 347 | 
            +
             | 
| 348 | 
            +
                if (depth == 1) {
         | 
| 349 | 
            +
                    first.wrap = last;
         | 
| 350 | 
            +
                }
         | 
| 351 | 
            +
                if (depth > 1) {
         | 
| 352 | 
            +
                    last = chainwrap(depth-1, first, new Wrap(last));
         | 
| 353 | 
            +
                }
         | 
| 354 | 
            +
             | 
| 355 | 
            +
                return last;
         | 
| 356 | 
            +
            }
         | 
| 357 | 
            +
             | 
| 358 | 
            +
            test("check jsDump recursion", function() {
         | 
| 359 | 
            +
                expect(4);
         | 
| 360 | 
            +
             | 
| 361 | 
            +
                var noref = chainwrap(0);
         | 
| 362 | 
            +
                var nodump = QUnit.jsDump.parse(noref);
         | 
| 363 | 
            +
                equal(nodump, '{\n  "wrap": undefined,\n  "first": true\n}');
         | 
| 364 | 
            +
             | 
| 365 | 
            +
                var selfref = chainwrap(1);
         | 
| 366 | 
            +
                var selfdump = QUnit.jsDump.parse(selfref);
         | 
| 367 | 
            +
                equal(selfdump, '{\n  "wrap": recursion(-1),\n  "first": true\n}');
         | 
| 368 | 
            +
             | 
| 369 | 
            +
                var parentref = chainwrap(2);
         | 
| 370 | 
            +
                var parentdump = QUnit.jsDump.parse(parentref);
         | 
| 371 | 
            +
                equal(parentdump, '{\n  "wrap": {\n    "wrap": recursion(-2),\n    "first": true\n  }\n}');
         | 
| 372 | 
            +
             | 
| 373 | 
            +
                var circref = chainwrap(10);
         | 
| 374 | 
            +
                var circdump = QUnit.jsDump.parse(circref);
         | 
| 375 | 
            +
                ok(new RegExp("recursion\\(-10\\)").test(circdump), "(" +circdump + ") should show -10 recursion level");
         | 
| 376 | 
            +
            });
         | 
| 377 | 
            +
             | 
| 378 | 
            +
            test("check (deep-)equal recursion", function() {
         | 
| 379 | 
            +
                var noRecursion = chainwrap(0);
         | 
| 380 | 
            +
                equal(noRecursion, noRecursion, "I should be equal to me.");
         | 
| 381 | 
            +
                deepEqual(noRecursion, noRecursion, "... and so in depth.");
         | 
| 382 | 
            +
             | 
| 383 | 
            +
                var selfref = chainwrap(1);
         | 
| 384 | 
            +
                equal(selfref, selfref, "Even so if I nest myself.");
         | 
| 385 | 
            +
                deepEqual(selfref, selfref, "... into the depth.");
         | 
| 386 | 
            +
             | 
| 387 | 
            +
                var circref = chainwrap(10);
         | 
| 388 | 
            +
                equal(circref, circref, "Or hide that through some levels of indirection.");
         | 
| 389 | 
            +
                deepEqual(circref, circref, "... and checked on all levels!");
         | 
| 390 | 
            +
            });
         | 
| 391 | 
            +
             | 
| 392 | 
            +
             | 
| 393 | 
            +
            test('Circular reference with arrays', function() {
         | 
| 394 | 
            +
             | 
| 395 | 
            +
                // pure array self-ref
         | 
| 396 | 
            +
                var arr = [];
         | 
| 397 | 
            +
                arr.push(arr);
         | 
| 398 | 
            +
             | 
| 399 | 
            +
                var arrdump = QUnit.jsDump.parse(arr);
         | 
| 400 | 
            +
             | 
| 401 | 
            +
                equal(arrdump, '[\n  recursion(-1)\n]');
         | 
| 402 | 
            +
                equal(arr, arr[0], 'no endless stack when trying to dump arrays with circular ref');
         | 
| 403 | 
            +
             | 
| 404 | 
            +
             | 
| 405 | 
            +
                // mix obj-arr circular ref
         | 
| 406 | 
            +
                var obj = {};
         | 
| 407 | 
            +
                var childarr = [obj];
         | 
| 408 | 
            +
                obj.childarr = childarr;
         | 
| 409 | 
            +
             | 
| 410 | 
            +
                var objdump = QUnit.jsDump.parse(obj);
         | 
| 411 | 
            +
                var childarrdump = QUnit.jsDump.parse(childarr);
         | 
| 412 | 
            +
             | 
| 413 | 
            +
                equal(objdump, '{\n  "childarr": [\n    recursion(-2)\n  ]\n}');
         | 
| 414 | 
            +
                equal(childarrdump, '[\n  {\n    "childarr": recursion(-2)\n  }\n]');
         | 
| 415 | 
            +
             | 
| 416 | 
            +
                equal(obj.childarr, childarr, 'no endless stack when trying to dump array/object mix with circular ref');
         | 
| 417 | 
            +
                equal(childarr[0], obj, 'no endless stack when trying to dump array/object mix with circular ref');
         | 
| 418 | 
            +
             | 
| 419 | 
            +
            });
         | 
| 420 | 
            +
             | 
| 421 | 
            +
             | 
| 422 | 
            +
            test('Circular reference - test reported by soniciq in #105', function() {
         | 
| 423 | 
            +
                var MyObject = function() {};
         | 
| 424 | 
            +
                MyObject.prototype.parent = function(obj) {
         | 
| 425 | 
            +
                    if (obj === undefined) { return this._parent; }
         | 
| 426 | 
            +
                    this._parent = obj;
         | 
| 427 | 
            +
                };
         | 
| 428 | 
            +
                MyObject.prototype.children = function(obj) {
         | 
| 429 | 
            +
                    if (obj === undefined) { return this._children; }
         | 
| 430 | 
            +
                    this._children = obj;
         | 
| 431 | 
            +
                };
         | 
| 432 | 
            +
             | 
| 433 | 
            +
                var a = new MyObject(),
         | 
| 434 | 
            +
                    b = new MyObject();
         | 
| 435 | 
            +
             | 
| 436 | 
            +
                var barr = [b];
         | 
| 437 | 
            +
                a.children(barr);
         | 
| 438 | 
            +
                b.parent(a);
         | 
| 439 | 
            +
             | 
| 440 | 
            +
                equal(a.children(), barr);
         | 
| 441 | 
            +
                deepEqual(a.children(), [b]);
         | 
| 442 | 
            +
            });
         | 
| 443 | 
            +
             | 
| 444 | 
            +
             | 
| 445 | 
            +
             | 
| 446 | 
            +
             | 
| 447 | 
            +
            (function() {
         | 
| 448 | 
            +
            	var reset = QUnit.reset;
         | 
| 449 | 
            +
            	function afterTest() {
         | 
| 450 | 
            +
            		ok( false, "reset should not modify test status" );
         | 
| 451 | 
            +
            	}
         | 
| 452 | 
            +
            	module("reset");
         | 
| 453 | 
            +
            	test("reset runs assertions", function() {
         | 
| 454 | 
            +
            		QUnit.reset = function() {
         | 
| 455 | 
            +
            			afterTest();
         | 
| 456 | 
            +
            			reset.apply( this, arguments );
         | 
| 457 | 
            +
            		};
         | 
| 458 | 
            +
            	});
         | 
| 459 | 
            +
            	test("reset runs assertions2", function() {
         | 
| 460 | 
            +
            		QUnit.reset = reset;
         | 
| 461 | 
            +
            	});
         | 
| 462 | 
            +
            })();
         | 
| 463 | 
            +
             | 
| 464 | 
            +
            if (typeof setTimeout !== 'undefined') {
         | 
| 465 | 
            +
            function testAfterDone(){
         | 
| 466 | 
            +
            	var testName = "ensure has correct number of assertions";
         | 
| 467 | 
            +
             | 
| 468 | 
            +
            	function secondAfterDoneTest(){
         | 
| 469 | 
            +
            		QUnit.config.done = [];
         | 
| 470 | 
            +
            		//QUnit.done = function(){};
         | 
| 471 | 
            +
            		//because when this does happen, the assertion count parameter doesn't actually
         | 
| 472 | 
            +
            		//work we use this test to check the assertion count.
         | 
| 473 | 
            +
            		module("check previous test's assertion counts");
         | 
| 474 | 
            +
            		test('count previous two test\'s assertions', function(){
         | 
| 475 | 
            +
            			var spans = document.getElementsByTagName('span'),
         | 
| 476 | 
            +
            			tests = [],
         | 
| 477 | 
            +
            			countNodes;
         | 
| 478 | 
            +
             | 
| 479 | 
            +
            			//find these two tests
         | 
| 480 | 
            +
            			for (var i = 0; i < spans.length; i++) {
         | 
| 481 | 
            +
            				if (spans[i].innerHTML.indexOf(testName) !== -1) {
         | 
| 482 | 
            +
            					tests.push(spans[i]);
         | 
| 483 | 
            +
            				}
         | 
| 484 | 
            +
            			}
         | 
| 485 | 
            +
             | 
| 486 | 
            +
            			//walk dom to counts
         | 
| 487 | 
            +
            			countNodes = tests[0].nextSibling.nextSibling.getElementsByTagName('b');
         | 
| 488 | 
            +
            			equal(countNodes[1].innerHTML, "99");
         | 
| 489 | 
            +
            			countNodes = tests[1].nextSibling.nextSibling.getElementsByTagName('b');
         | 
| 490 | 
            +
            			equal(countNodes[1].innerHTML, "99");
         | 
| 491 | 
            +
            		});
         | 
| 492 | 
            +
            	}
         | 
| 493 | 
            +
            	QUnit.config.done = [];
         | 
| 494 | 
            +
            	QUnit.done(secondAfterDoneTest);
         | 
| 495 | 
            +
             | 
| 496 | 
            +
            	module("Synchronous test after load of page");
         | 
| 497 | 
            +
             | 
| 498 | 
            +
            	asyncTest('Async test', function(){
         | 
| 499 | 
            +
            		start();
         | 
| 500 | 
            +
            		for (var i = 1; i < 100; i++) {
         | 
| 501 | 
            +
            			ok(i);
         | 
| 502 | 
            +
            		}
         | 
| 503 | 
            +
            	});
         | 
| 504 | 
            +
             | 
| 505 | 
            +
            	test(testName, 99, function(){
         | 
| 506 | 
            +
            		for (var i = 1; i < 100; i++) {
         | 
| 507 | 
            +
            			ok(i);
         | 
| 508 | 
            +
            		}
         | 
| 509 | 
            +
            	});
         | 
| 510 | 
            +
             | 
| 511 | 
            +
            	//we need two of these types of tests in order to ensure that assertions
         | 
| 512 | 
            +
            	//don't move between tests.
         | 
| 513 | 
            +
            	test(testName + ' 2', 99, function(){
         | 
| 514 | 
            +
            		for (var i = 1; i < 100; i++) {
         | 
| 515 | 
            +
            			ok(i);
         | 
| 516 | 
            +
            		}
         | 
| 517 | 
            +
            	});
         | 
| 518 | 
            +
             | 
| 519 | 
            +
             | 
| 520 | 
            +
            }
         | 
| 521 | 
            +
             | 
| 522 | 
            +
            QUnit.done(testAfterDone);
         | 
| 523 | 
            +
             | 
| 524 | 
            +
            }
         |