text:
const {
	start,
	startMethod,
	Awaiter,
	Checkpoint,
	Cancellation,
	CheckpointResult,
	NowThen
} = require("./index.js");

var testCases = {
	// mark a test ID with '*' to ignore it
	"*CRTK-IGNORE":
	function *(log, assert) {
		// an example of disabled test
	},

	//
	// starting, resuming and delivering result
	//
	"CRTK-SRC-A-1":
	function *(log, assert) {
		log("Test: multiple coroutines can be started");
		var c1,c1r,c2,c2r,c3,c3r;
		c1 = start(function *() {
			c1r = true;
		});
		c2 = start(function *() {
			c2r = true;
		});
		c3 = start(function *() {
			c3r = true;
		});
		c1.await(SYNC), yield *SYNCW();
		c2.await(SYNC), yield *SYNCW();
		c3.await(SYNC), yield *SYNCW();
		assert(c1r && c2r && c3r, "All coroutines have run");
	},

	"CRTK-SRC-A-2":
	function *(log, assert) {
		log("Test: nested coroutines can be started");
		var c1, c1r, c2, c2r;
		c1 = start(function *() {
			c2 = start(function *() {
				c2r = true;
			});
			c1r = true;
		});
		c1.await(SYNC), yield *SYNCW();
		// after c1 completed, c2 should be already set by it
		c2.await(SYNC), yield *SYNCW();
	},

	"CRTK-SRC-A-3":
	function *(log, assert) {
		log("Test: coroutine can start with parameters");
		var c1 = start(function *(p1, p2, p3) {
			assert(p1 == 1, "P1 ok");
			assert(p2 == 2, "P2 ok");
			assert(p3 == 3, "P3 ok");
		}, 1, 2, 3);
		c1.await(SYNC), yield *SYNCW();
	},

	"CRTK-SRC-A-4":
	function *(log, assert) {
		log("Test: coroutine can start as methods with parameters");
		var object = {
			f: function *(p1, p2, p3) {
				assert(this == object, "Valid this object");
				assert(p1 == 1, "P1 ok");
				assert(p2 == 2, "P2 ok");
				assert(p3 == 3, "P3 ok");
			}
		};
		var c1 = object[startMethod] ("f", 1, 2, 3);
		c1.await(SYNC), yield *SYNCW();
	},

	"CRTK-SRC-A-5":
	function *(log, assert) {
		log("Test: coroutine can start from plain function");
		var r;
		start(function() { r = true; }).await(SYNC), yield *SYNCW();
		assert(r, "Plain function invoked");
	},

	"CRTK-SRC-A-5-1": // NJS 7+
	function *(log, assert) {
		log("Test: coroutine can start from async function");
		var r;
		start(async function() { r = true; }).await(SYNC), yield *SYNCW();
		assert(r, "Async function invoked");
	},

	"CRTK-SRC-A-6":
	function *(log, assert) {
		log("Test: coroutine can return value");
		var v = (start(function *() { return 10; }).await(SYNC), yield *SYNCW());
		assert(v == 10, "Expected value returned");
	},

	"CRTK-SRC-A-6-1":
	function *(log, assert) {
		log("Test: plain function coroutine can return value");
		var v = (start(function() { return 10; }).await(SYNC), yield *SYNCW());
		assert(v == 10, "Expected value returned");
	},

	"CRTK-SRC-A-6-2": // NJS 7+
	function *(log, assert) {
		log("Test: async function coroutine can return value");
		var v = (start(async function() { return 10; }).await(SYNC), yield *SYNCW());
		assert(v == 10, "Expected value returned");
	},

	"CRTK-SRC-A-7":
	function *(log, assert) {
		log("Test: coroutine can throw error");
		var err = {};
		try {
			start(function *() { throw err; }).await(SYNC), yield *SYNCW();
		} catch (e) {
			assert(e == err, "Expected value thrown");
			return;
		}
		assert(false, "Expected a throw");
	},

	"CRTK-SRC-A-7-1":
	function *(log, assert) {
		log("Test: plain function coroutine can throw error");
		var err = {};
		try {
		start(function () { throw err; }).await(SYNC), yield *SYNCW();
		} catch (e) {
			assert(e == err, "Expected value thrown");
			return;
		}
		assert(false, "Expected a throw");
	},

	"CRTK-SRC-A-7-2": // NJS 7+
	function *(log, assert) {
		log("Test: async function coroutine can throw error");
		var err = {};
		try {
		start(async function () { throw err; }).await(SYNC), yield *SYNCW();
		} catch (e) {
			assert(e == err, "Expected value thrown");
			return;
		}
		assert(false, "Expected a throw");
	},

	"CRTK-SRC-A-8":
	function *(log, assert) {
		log("Test: coroutine code starts asynchronously");
		var t = false, c = start(function *() {
				t = true;
			});
		assert(!t, "Coroutine not yet performed");
		c.await(SYNC), yield *SYNCW();
		assert(t, "Coroutine performed");
	},

	"CRTK-SRC-A-8-1":
	function *(log, assert) {
		log("Test: plain function coroutine code starts asynchronously");
		var t = false, c = start(function() {
				t = true;
			});
		assert(!t, "Coroutine not yet performed");
		c.await(SYNC), yield *SYNCW();
		assert(t, "Coroutine performed");
	},

	"CRTK-SRC-A-9":
	function *(log, assert) {
		log("Test: coroutine stores the result");
		var c = start(function *() {
			return 100;
		});
		c.await(SYNC), yield *SYNCW();
		assert(c.result == 100, "Expected result is stored");
	},

	"CRTK-SRC-A-10":
	function *(log, assert) {
		log("Test: coroutine stores the error");
		var c = start(function *() {
			throw "error";
		});
		try {
			c.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw");
		} catch (e) {
			assert(c.error == "error", "Expected error is stored");
		}
	},

	//
	// cancellation
	//
	"CRTK-SRC-B-1":
	function *(log, assert) {
		log("Test: coroutine can be canceled");
		var c = start(function *() {
			setTimeout(SYNC, 100), yield *SYNCW();
		});
		c.cancel();
		try {
			c.await(SYNC), yield *SYNCW();
		} catch(e) {
			assert(!(e instanceof Cancellation), "Awaiting on canceled coroutine throws Error instead of Cancellation");
			assert(c.error instanceof Cancellation, "Cancellation is stored in canceled coroutine's handle.error");
			return;
		}
		assert(false, "Awaiting canceled coroutine must throw");
	},

	"CRTK-SRC-B-2":
	function *(log, assert) {
		log("Test: coroutine can be canceled with a message");
		var c = start(function *() {
			try {
				setTimeout(SYNC, 100), yield *SYNCW();
			} catch(e) {
				assert((e instanceof Cancellation) && e.message == "test",
					"Cancellation with a valid message");
				throw e;
			}
		});
		c.cancel("test");
		try {
			c.await(SYNC), yield *SYNCW();
		} catch(e) {
			return;
		}
		assert(false, "Awaiting canceled coroutine must throw");
	},

	"CRTK-SRC-B-3":
	function *(log, assert) {
		log("Test: cancellation callback is triggered on cancellation");
		var got, c = start(function *() {
			try {
				setTimeout(SYNC, 100), yield *SYNCW.withCancel(function(msg) {
					got = msg;
				});
			} catch(e) {
				assert((e instanceof Cancellation) && e.message == "test",
					"Cancellation with a valid message");
				throw e;
			}
		});
		c.cancel("test");
		try {
			c.await(SYNC), yield *SYNCW();
		} catch(e) {
			return;
		}
		assert(got == "test", "Cancellation callback called and got the valid parameter");
	},

	"CRTK-SRC-B-4":
	function *(log, assert) {
		log("Test: coroutine that traps cancellation and returns normally is a normal finish");
		var c = start(function *() {
			try {
				setTimeout(SYNC, 100), yield *SYNCW();
			} catch(e) {
				return 200;
			}
		});
		c.cancel("test");
		var result = (c.await(SYNC), yield *SYNCW());
		assert(result == 200, "Coroutine returned normal value");
	},

	"CRTK-SRC-B-5":
	function *(log, assert) {
		log("Test: SYNCTL throws on cancellation");
		var c = start(function *() {
			setTimeout(SYNCTL, 100), yield *SYNCW();
		});
		c.cancel();
		try {
			c.await(SYNC), yield *SYNCW();
		} catch(e) {
			assert(!(e instanceof Cancellation), "Awaiting on canceled coroutine throws Error instead of Cancellation");
			assert(c.error instanceof Cancellation, "Cancellation is stored in canceled coroutine's handle.error");
			return;
		}
		assert(false, "Awaiting canceled coroutine must throw");
	},

	"CRTK-SRC-B-6":
	function *(log, assert) {
		log("Test: cancellation of self throws immediately");
		var c = start(function *() {
			c.cancel();
		});
		try {
			c.await(SYNC), yield *SYNCW();
		} catch(e) {
			assert(!(e instanceof Cancellation), "Awaiting on canceled coroutine throws Error instead of Cancellation");
			assert(c.error instanceof Cancellation, "Cancellation is stored in canceled coroutine's handle.error");
			return;
		}
		assert(false, "Awaiting canceled coroutine must throw");
	},

	"CRTK-SRC-B-7":
	function *(log, assert) {
		log("Test: Cancellation may not be constructed manually");
		var ok = false;
		try {
			new Cancellation("cancellation msg");
		} catch(e) {
			ok = true;
		}
		assert(ok, "Error is thrown on manual construction of Cancellation");
	},

	//
	// pseudo-global variables
	//
	"CRTK-SRC-C-1":
	function *(log, assert) {
		log("Test: magic pseudo-globals differ for different coroutines");
		var rSYNC1, rSYNC2, rSYNCTL1, rSYNCTL2, rSYNCW1, rSYNCW2, rCRTN1, rCRTN2;
		var c1 = start(function *() {
			rSYNC1 = SYNC;
			rSYNCTL1 = SYNCTL;
			rSYNCW1 = SYNCW;
			rCRTN1 = CRTN;
		}), c2 = start(function *() {
			rSYNC2 = SYNC;
			rSYNCTL2 = SYNCTL;
			rSYNCW2 = SYNCW;
			rCRTN2 = CRTN;
		});
		Checkpoint.allOf(c1, c2).await(SYNC), yield *SYNCW();
		assert(rSYNC1 != rSYNC2, "SYNCs differ");
		assert(rSYNCTL1 != rSYNCTL2, "SYNCTLs differ");
		assert(rSYNCW1 != rSYNCW2, "SYNCWs differ");
		assert(rCRTN1 != rCRTN2, "CRTNs differ");
	},

	"CRTK-SRC-C-2":
	function *(log, assert) {
		log("Test: magic pseudo-globals only defined inside coroutine");
		var typeofSYNC, typeofSYNCTL, typeofSYNCW, typeofCRTN;
		function extractor() {
			typeofSYNC = typeof(SYNC);
			typeofSYNCTL = typeof(SYNCTL);
			typeofSYNCW = typeof(SYNCW);
			typeofCRTN = typeof(CRTN);
		}
		setTimeout(extractor, 0);
		// ensure the plain timeout triggers
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(typeofSYNC == "undefined", "SYNC undefined");
		assert(typeofSYNCTL == "undefined", "SYNCTL undefined");
		assert(typeofSYNCW == "undefined", "SYNCW undefined");
		assert(typeofCRTN == "undefined", "CRTN undefined");

		// now try from coroutine (i. e. from ourselves)
		extractor();
		assert(typeofSYNC != "undefined", "SYNC defined");
		assert(typeofSYNCTL != "undefined", "SYNCTL defined");
		assert(typeofSYNCW != "undefined", "SYNCW defined");
		assert(typeofCRTN != "undefined", "CRTN defined");
	},

	"CRTK-SRC-C-3":
	function *(log, assert) {
		log("Test: CRTN is same down the coroutine stack");
		var sampleCRTN = CRTN;
		yield *(function *() {
			assert(CRTN == sampleCRTN, "CRTN same within a subgenerator");
		}());
		(function() {
			assert(CRTN == sampleCRTN, "CRTN same within a subfunction");
		})();
	},

	//
	// behaviour of SYNC
	//
	"CRTK-SRC-D-1":
	function *(log, assert) {
		log("Test: SYNC resumes coroutine asynchronously");
		var t1 = false, t2 = false, c = start(function *() {
				function asyncDo(callback) {
					setTimeout(function() {
						callback();
						t2 = !t1; // CRT will set t1=true on resumption,
						// ensure it hasn't happened at this point
					}, 0);
				}

				asyncDo(SYNC), yield *SYNCW();
				t1 = true;
			});
		c.await(SYNC), yield *SYNCW();
		assert(t2, "c did not resume inside the callback");
	},

	"CRTK-SRC-D-2":
	function *(log, assert) {
		log("Test: SYNC is one-shot");
		SYNC(null, 100);
		SYNC(null, 200);
		assert((yield *SYNCW()) == 100, "The yield *SYNCW() value is of first SYNC call");
		assert((SYNC(null, 300), yield *SYNCW()) == 300, "Second SYNC had no post-effects");
	},

	"CRTK-SRC-D-3":
	function *(log, assert) {
		log("Test: SYNC invoked from the coroutine triggers next SYNCW");
		SYNC(null, 100);
		var c = SYNC;
		var result = (setTimeout(function() { c(null, 200); }, 100), yield *SYNCW());
		assert(result == 100, "The yield *SYNCW() value is of first SYNC call");
	},

	"CRTK-SRC-D-4":
	function *(log, assert) {
		log("Test: SYNC is different instance after each SYNCW");
		var s1 = SYNC;
		SYNC(), yield *SYNCW();
		assert(SYNC != s1, "SYNC changed afte yield *SYNCW()");
	},

	//
	// Awaiter
	//
	"CRTK-SRC-E-1":
	function *(log, assert) {
		log("Test: Awaiter forwards the call to it");
		var aw = Awaiter();
		setTimeout(function () { aw(null, 100); }, 250);
		var result = (aw.await(SYNC), yield *SYNCW());
		assert(result == 100, "Valid result from awaiter");
	},

	"CRTK-SRC-E-2":
	function *(log, assert) {
		log("Test: Awaiter allows to await result after completed");
		var aw = Awaiter();
		aw(null, 100);
		assert(aw.done, "Awaiter finished");
		assert((aw.await(SYNC), yield *SYNCW()) == 100, "Got the result");
	},

	"CRTK-SRC-E-3":
	function *(log, assert) {
		log("Test: Awaiter is one-shot");
		var aw = Awaiter();
		aw(null, 100);
		aw(null, 200);
		assert((aw.await(SYNC), yield *SYNCW()) == 100, "Got the result from 1st call");
	},

	"CRTK-SRC-E-4":
	function *(log, assert) {
		log("Test: Awaiter invokes callback asynchronously");
		var aw1 = Awaiter(), t = false;
		aw1.await(function () { t = true; });
		aw1();
		assert(t == false, "Awaiter callback code does not run immediately");
		// give it a chance to trigger
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t == true, "Awaiter callback code triggered at all");
	},

	//
	// feedback events
	//
	"CRTK-SRC-F-1":
	function *(log, assert) {
		log("Test: event listeners are invoked with parameters");
		var c1 = 0,c2 = 0;
		CRTN.on("test", function(c) { c1 = c; });
		CRTN.on("test", function(c) { c2 = c; });
		CRTN.emit("test", 100);
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(c1 == 100 && c2 == 100, "Both callbacks were called with valid params");
	},

	"CRTK-SRC-F-2":
	function *(log, assert) {
		log("Test: event listener is invoked asynchronously");
		var c1 = 0;
		CRTN.on("test", function() { c1 = 100; });
		CRTN.emit("test");
		assert(c1 == 0, "Listener did not trigger immediately");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(c1 == 100, "Listener triggered after all");
	},

	"CRTK-SRC-F-3":
	function *(log, assert) {
		log("Test: unsubscribed event listener is not invoked");
		var c1 = 0;
		CRTN.emit("test"); // first emit then subscribe
		CRTN.on("test", function() { c1 = 100; });
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(c1 == 0, "Listener did not trigger");
	},

	"CRTK-SRC-F-4":
	function *(log, assert) {
		log("Test: event listener from other channel is not called");
		var t1 = false, t2 = false;
		CRTN.on("test", function() { t1 = true; });
		CRTN.on("test1", function() { t2 = true; });
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1, "Listener on 'test' triggered");
		assert(!t2, "Listener on 'test1' did not trigger");
	},

	"CRTK-SRC-F-5":
	function *(log, assert) {
		log("Test: removed event is not called");
		var t1 = false, t2 = false, c;
		CRTN.on("test", function() { t1 = true; });
		CRTN.on("test", c = function() { t2 = true; });
		CRTN.removeListener("test", c);
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1, "Listener triggered");
		assert(!t2, "Removed listener did not trigger");
	},

	"CRTK-SRC-F-6":
	function *(log, assert) {
		log("Test: same listener is not added and called twice");
		var t1 = 0, c;
		CRTN.on("test", c = function() { t1++; });
		CRTN.on("test", c);
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1 == 1, "Listener triggered once");
	},

	"CRTK-SRC-F-7":
	function *(log, assert) {
		log("Test: once-listener only triggers once");
		var t1 = 0, t2 = 0;
		CRTN.on("test", function() { t1++; });
		CRTN.once("test", function() { t2++; });
		CRTN.emit("test");
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1 == 2, "Plain listener triggered twice");
		assert(t2 == 1, "Once-listener triggered once");
	},

	"CRTK-SRC-F-8":
	function *(log, assert) {
		log("Test: removeAllListeners removes all listeners");
		var t1 = 0, t2 = 0;
		CRTN.on("test", function() { t1++; });
		CRTN.once("test", function() { t2++; });
		CRTN.removeAllListeners("test");
		CRTN.emit("test");
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1 == 0, "Plain listener did not trigger");
		assert(t2 == 0, "Once-listener did not trigger");
	},

	"CRTK-SRC-F-9":
	function *(log, assert) {
		log("Test: removeAllListeners does not affect other channels");
		var t1 = 0, t2 = 0;
		CRTN.on("test", function() { t1++; });
		CRTN.once("test", function() { t2++; });
		CRTN.removeAllListeners("test1");
		CRTN.emit("test");
		CRTN.emit("test");
		// give them chance to work
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t1 == 2, "Plain listener triggered twice");
		assert(t2 == 1, "Once-listener triggered once");
	},

	//
	// checkpoint
	//
	"CRTK-SRC-G-1":
	function *(log, assert) {
		log("Test: allOf waits for all awaitables");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
			});
		Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished");
		assert(f2, "Coroutine 2 finished");
		assert(f3, "Coroutine 3 finished");
	},

	"CRTK-SRC-G-2":
	function *(log, assert) {
		log("Test: anyOf waits for soonest awaitable");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
			});
		Checkpoint.anyOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished on anyOf");
		assert(!f2, "Coroutine 2 not finished on anyOf");
		assert(!f3, "Coroutine 3 not finished on anyOf");

		Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished at all");
		assert(f2, "Coroutine 2 finished at all");
		assert(f3, "Coroutine 3 finished at all");
	},

	"CRTK-SRC-G-3":
	function *(log, assert) {
		log("Test: allOf waits for all even if error");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw new Error("test error");
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
			});
		var thrown = false;
		try {
			Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		} catch(e) {
			thrown = true;
			assert(e instanceof CheckpointResult &&
				e.errors.length == 1 &&
				e.errors[0].message == "test error",
				"Catched the expected error");
		}
		assert(f1, "Coroutine 1 finished");
		assert(f2, "Coroutine 2 finished");
		assert(f3, "Coroutine 3 finished");
		assert(thrown, "Expected error was thrown");
	},

	"CRTK-SRC-G-4":
	function *(log, assert) {
		log("Test: allOf doesn't wait for remaining if stopOnFirstError");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw new Error("test error");
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
			});
		var thrown = false;
		try {
			Checkpoint.allOf(ch1, ch2, ch3).stopOnFirstError(true)
			.await(SYNC), yield *SYNCW();
		} catch(e) {
			thrown = true;
		}
		assert(f1, "Coroutine 1 finished");
		assert(!f2, "Coroutine 2 not finished");
		assert(!f3, "Coroutine 3 not finished");
		assert(thrown, "Error was thrown");

		try {
			thrown = false;
			Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		} catch(e) {
			thrown = true;
		}
		assert(f1, "Coroutine 1 finished at all");
		assert(f2, "Coroutine 2 finished at all");
		assert(f3, "Coroutine 3 finished at all");
		assert(thrown, "Error was persistently thrown on second await");
	},

	"CRTK-SRC-G-5":
	function *(log, assert) {
		log("Test: anyOf cancels remaining if cancelAbandoned");
		var f1 = false, f2 = false, f3 = false,
			c1 = false, c2 = false, c3 = false;
		var ch1 = start(function *() {
				try {
					setTimeout(SYNC, 100); yield *SYNCW();
					f1 = true;
				} catch (e) {
					c1 = true;
				}
			}),
			ch2 = start(function *() {
				try {
					setTimeout(SYNC, 250); yield *SYNCW();
					f2 = true;
				} catch (e) {
					c2 = true;
				}
			}),
			ch3 = start(function *() {
				try {
					setTimeout(SYNC, 500); yield *SYNCW();
					f3 = true;
				} catch (e) {
					c3 = true;
				}
			});
		Checkpoint.anyOf(ch1, ch2, ch3).cancelAbandoned(true)
		.await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished on anyOf");
		assert(!f2, "Coroutine 2 not finished on anyOf");
		assert(!f3, "Coroutine 3 not finished on anyOf");

		Checkpoint.allOf(ch1, ch2, ch3).await(SYNCTL), yield *SYNCW();
		assert(f1 && !c1, "Coroutine 1 finished at all, not canceled");
		assert(!f2 && c2, "Coroutine 2 canceled in the end");
		assert(!f3 && c3, "Coroutine 3 canceled in the end");
	},

	"CRTK-SRC-G-6":
	function *(log, assert) {
		log("Test: allOf cancels remaining if stopOnFirstError and cancelAbandoned");
		var f1 = false, f2 = false, f3 = false,
			c1 = false, c2 = false, c3 = false;
		var ch1 = start(function *() {
				try {
					setTimeout(SYNC, 100); yield *SYNCW();
					f1 = true;
				} catch (e) {
					c1 = true;
				}
				throw new Error("test error");
			}),
			ch2 = start(function *() {
				try {
					setTimeout(SYNC, 250); yield *SYNCW();
					f2 = true;
				} catch (e) {
					c2 = true;
				}
			}),
			ch3 = start(function *() {
				try {
					setTimeout(SYNC, 500); yield *SYNCW();
					f3 = true;
				} catch (e) {
					c3 = true;
				}
			});
		Checkpoint.allOf(ch1, ch2, ch3)
		.stopOnFirstError(true)
		.cancelAbandoned(true)
		.await(SYNCTL), yield *SYNCW();
		assert(f1, "Coroutine 1 finished on allOf");
		assert(!f2, "Coroutine 2 not finished on allOf");
		assert(!f3, "Coroutine 3 not finished on allOf");

		Checkpoint.allOf(ch1, ch2, ch3).await(SYNCTL), yield *SYNCW();
		assert(f1 && !c1, "Coroutine 1 finished at all, not canceled");
		assert(!f2 && c2, "Coroutine 2 canceled in the end");
		assert(!f3 && c3, "Coroutine 3 canceled in the end");
	},

	"CRTK-SRC-G-7":
	function *(log, assert) {
		log("Test: Checkpoint has .done property");
		var aw = Awaiter(), cp = Checkpoint.allOf(aw);
		assert(!cp.done, "Checkpoint .done not set before done");
		aw();
		cp.await(SYNC), yield *SYNCW();
		assert(cp.done, "Checkpoint .done set after done");
	},

	"CRTK-SRC-G-8":
	function *(log, assert) {
		log("Test: Checkpoint has .results property");
		var cp = Checkpoint.allOf();
		assert(cp.results instanceof Array, "Checkpoint has .results array property");
	},

	"CRTK-SRC-G-9":
	function *(log, assert) {
		log("Test: Checkpoint has .errors property");
		var cp = Checkpoint.allOf();
		assert(cp.errors instanceof Array, "Checkpoint has .errors array property");
	},

	"CRTK-SRC-G-10":
	function *(log, assert) {
		log("Test: Null checkpoint is a valid awaitable");
		var cp = Checkpoint.allOf(), t = false;
		cp.await(function() { t = true; });
		setTimeout(SYNC, 100); yield *SYNCW(); // give it chance to work
		assert(t, "Null checkpoint awaited successfully");
	},

	"CRTK-SRC-G-11":
	function *(log, assert) {
		log("Test: Checkpoint.cancel must propagate");
		var t1 = false, c1 = start(function *() {
			setTimeout(SYNC, 100), yield *SYNCW(function(cm) { t1 = cm; });
		});
		var t2 = false, c2 = start(function *() {
			setTimeout(SYNC, 100), yield *SYNCW(function(cm) { t2 = cm; });
		});
		var t3 = false, c3 = start(function *() {
			setTimeout(SYNC, 100), yield *SYNCW(function(cm) { t3 = cm; });
		});
		var cp = Checkpoint.allOf(c1, c2, c3);
		cp.cancel("Y"); // this message must not be used
		try {
			cp.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw (checkpoint)");
		} catch (e) {
		}
		try {
			c1.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw (coroutine 1)");
		} catch (e) {
		}
		try {
			c2.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw (coroutine 2)");
		} catch (e) {
		}
		try {
			c3.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw (coroutine 3)");
		} catch (e) {
		}
		setTimeout(SYNC, 150); yield *SYNCW();
		assert(t1 == "Y" && t2 == "Y" && t3 == "Y",
			"Checkpoint cancellation has propagated correctly");
	},

	"CRTK-SRC-G-12":
	function *(log, assert) {
		log("Test: Checkpoint.cancel is valid after checkpoint is done");
		var aw = Awaiter(), cp = Checkpoint.allOf(aw);
		aw();
		cp.await(SYNC), yield *SYNCW();
		cp.cancel(); // must not fail
	},

	"CRTK-SRC-G-13":
	function *(log, assert) {
		log("Test: CheckpointResult implements toString");
		var cp = Checkpoint.allOf();
		var result = (cp.await(SYNC), yield *SYNCW());
		assert(result.toString().match(/CheckpointResult/),
			"CheckpointResult toString worked");
	},

	"CRTK-SRC-G-14": // NJS 7+
	function *(log, assert) {
		log("Test: Checkpoint accepts iterators and promises");
		var cp = Checkpoint.allOf(
			function *(x) { return x + 1; }(100),
			async function(x) { return x + 3; }(200));
		var result = (cp.await(SYNC), yield *SYNCW());
		assert(result.results[0] == 101 || result.results[1] == 101,
			"Iterator based checkpoint entry returned the expected result");
		assert(result.results[0] == 203 || result.results[1] == 203,
			"Promise based checkpoint entry returned the expected result");
	},

	"CRTK-SRC-G-15": // NJS 7+
	function *(log, assert) {
		log("Test: Checkpoint accepts iterators and promises, and they may throw");
		var cp = Checkpoint.allOf(
			function *(x) { throw x + 1; }(100),
			async function(x) { throw x + 3; }(200));
		var result = [];
		try {
			cp.await(SYNC), yield *SYNCW();
		} catch (e) {
			result = e;
		}
		assert(result.errors[0] == 101 || result.errors[1] == 101,
			"Iterator based checkpoint entry threw the expected result");
		assert(result.errors[0] == 203 || result.errors[1] == 203,
			"Promise based checkpoint entry threw the expected result");
	},

	"CRTK-SRC-G-16": // NJS 7+
	function *(log, assert) {
		log("Test: Checkpoint rejects invalid entries");
		var thrown = 0,
			badOfferings = [
				0,
				null,
				1,
				"string",
				"",
				{}
			];
		for (var offering of badOfferings) {
			try {
				Checkpoint.allOf(offering);
			} catch (e) {
				thrown++;
			}
		}

		assert(thrown == badOfferings.length,
			"Checkpoint rejected all the invalid entries");
	},

	"CRTK-SRC-G-17":
	function *(log, assert) {
		log("Test: CheckpointResult may not be constructed manually");
		var ok = false;
		try {
			new CheckpointResult([], []);
		} catch(e) {
			ok = true;
		}
		assert(ok, "Error is thrown on manual construction of CheckpointResult");
	},

	"CRTK-SRC-G-18":
	function *(log, assert) {
		log("Test: allIn waits for all awaitables in array and puts results by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				return "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				return "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				return "C3";
			});
		var cp = (Checkpoint.allIn([ch2, ch1, ch3]).await(SYNC), yield *SYNCW());
		assert(f1, "Coroutine 1 finished");
		assert(f2, "Coroutine 2 finished");
		assert(f3, "Coroutine 3 finished");
		assert(cp.results[0] == "C2", "Coroutine 2 result got into valid slot");
		assert(cp.results[1] == "C1", "Coroutine 1 result got into valid slot");
		assert(cp.results[2] == "C3", "Coroutine 3 result got into valid slot");
	},

	"CRTK-SRC-G-19":
	function *(log, assert) {
		log("Test: allIn waits for all awaitables in dictionary and puts results by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				return "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				return "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				return "C3";
			});
		var cp = (Checkpoint.allIn({ a: ch2, b: ch1, c: ch3 }).await(SYNC), yield *SYNCW());
		assert(f1, "Coroutine 1 finished");
		assert(f2, "Coroutine 2 finished");
		assert(f3, "Coroutine 3 finished");
		assert(cp.results.a == "C2", "Coroutine 2 result got into valid slot");
		assert(cp.results.b == "C1", "Coroutine 1 result got into valid slot");
		assert(cp.results.c == "C3", "Coroutine 3 result got into valid slot");
	},

	"CRTK-SRC-G-20":
	function *(log, assert) {
		log("Test: anyIn waits for soonest awaitable in array and puts results by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				return "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				return "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				return "C3";
			});
		var cp = (Checkpoint.anyIn([ch2, ch1, ch3]).await(SYNC), yield *SYNCW());
		assert(f1, "Coroutine 1 finished on anyOf");
		assert(!f2, "Coroutine 2 not finished on anyOf");
		assert(!f3, "Coroutine 3 not finished on anyOf");

		Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished at all");
		assert(f2, "Coroutine 2 finished at all");
		assert(f3, "Coroutine 3 finished at all");

		assert(typeof (cp.results[0]) == "undefined", "Coroutine 2 result correctly dismissed");
		assert(cp.results[1] == "C1", "Coroutine 1 result got into valid slot");
		assert(typeof (cp.results[2]) == "undefined", "Coroutine 3 result correctly dismissed");
	},

	"CRTK-SRC-G-21":
	function *(log, assert) {
		log("Test: anyIn waits for soonest awaitable in dictionary and puts results by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				return "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				return "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				return "C3";
			});
		var cp = (Checkpoint.anyIn({ a: ch2, b: ch1, c: ch3 }).await(SYNC), yield *SYNCW());
		assert(f1, "Coroutine 1 finished on anyOf");
		assert(!f2, "Coroutine 2 not finished on anyOf");
		assert(!f3, "Coroutine 3 not finished on anyOf");

		Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		assert(f1, "Coroutine 1 finished at all");
		assert(f2, "Coroutine 2 finished at all");
		assert(f3, "Coroutine 3 finished at all");

		assert(typeof (cp.results.a) == "undefined", "Coroutine 2 result correctly dismissed");
		assert(cp.results.b == "C1", "Coroutine 1 result got into valid slot");
		assert(typeof (cp.results.c) == "undefined", "Coroutine 3 result correctly dismissed");
	},

	///
	"CRTK-SRC-G-22":
	function *(log, assert) {
		log("Test: allIn waits for all awaitables in array and puts errors by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				throw "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				throw "C3";
			});
		try {
			Checkpoint.allIn([ch2, ch1, ch3]).await(SYNC), yield *SYNCW();
			assert(false, "Throw expected");
		} catch (cp) {
			if (cp.isAssertionFailure) throw cp; // assersion, rethrow
			assert(f1, "Coroutine 1 finished");
			assert(f2, "Coroutine 2 finished");
			assert(f3, "Coroutine 3 finished");
			assert(cp.errors[0] == "C2", "Coroutine 2 error got into valid slot");
			assert(cp.errors[1] == "C1", "Coroutine 1 error got into valid slot");
			assert(cp.errors[2] == "C3", "Coroutine 3 error got into valid slot");
		}
	},

	"CRTK-SRC-G-23":
	function *(log, assert) {
		log("Test: allIn waits for all awaitables in dictionary and puts errors by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				throw "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				throw "C3";
			});
		try {
			Checkpoint.allIn({ a: ch2, b: ch1, c: ch3 }).await(SYNC), yield *SYNCW();
			assert(false, "Throw expected");
		} catch (cp) {
			if (cp.isAssertionFailure) throw cp; // assersion, rethrow
			assert(f1, "Coroutine 1 finished");
			assert(f2, "Coroutine 2 finished");
			assert(f3, "Coroutine 3 finished");
			assert(cp.errors.a == "C2", "Coroutine 2 error got into valid slot");
			assert(cp.errors.b == "C1", "Coroutine 1 error got into valid slot");
			assert(cp.errors.c == "C3", "Coroutine 3 error got into valid slot");
		}
	},

	"CRTK-SRC-G-24":
	function *(log, assert) {
		log("Test: anyIn waits for soonest awaitable in array and puts errors by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				throw "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				throw "C3";
			});
		var cp;
		try {
			Checkpoint.anyIn([ch2, ch1, ch3]).await(SYNC), yield *SYNCW();
			assert(false, "Throw expected");
		} catch (e) {
			if (e.isAssertionFailure) throw e; // assersion, rethrow
			cp = e;
		}
		assert(f1, "Coroutine 1 finished on anyOf");
		assert(!f2, "Coroutine 2 not finished on anyOf");
		assert(!f3, "Coroutine 3 not finished on anyOf");

		try {
			Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		    assert(false, "Throw expected");
		} catch (e) {
			if (e.isAssertionFailure) throw e; // assersion, rethrow
			assert(f1, "Coroutine 1 finished at all");
			assert(f2, "Coroutine 2 finished at all");
			assert(f3, "Coroutine 3 finished at all");
		}

		assert(typeof (cp.errors[0]) == "undefined", "Coroutine 2 error correctly dismissed");
		assert(cp.errors[1] == "C1", "Coroutine 1 error got into valid slot");
		assert(typeof (cp.errors[2]) == "undefined", "Coroutine 3 error correctly dismissed");
	},

	"CRTK-SRC-G-25":
	function *(log, assert) {
		log("Test: anyIn waits for soonest awaitable in dictionary and puts errors by key");
		var f1 = false, f2 = false, f3 = false;
		var ch1 = start(function *() {
				setTimeout(SYNC, 100); yield *SYNCW();
				f1 = true;
				throw "C1";
			}),
			ch2 = start(function *() {
				setTimeout(SYNC, 250); yield *SYNCW();
				f2 = true;
				throw "C2";
			}),
			ch3 = start(function *() {
				setTimeout(SYNC, 500); yield *SYNCW();
				f3 = true;
				throw "C3";
			});
		var cp;
		try {
			Checkpoint.anyIn({ a: ch2, b: ch1, c: ch3 }).await(SYNC), yield *SYNCW();
			assert(false, "Throw expected");
		} catch (e) {
			if (e.isAssertionFailure) throw e; // assersion, rethrow
			assert(f1, "Coroutine 1 finished on anyOf");
			assert(!f2, "Coroutine 2 not finished on anyOf");
			assert(!f3, "Coroutine 3 not finished on anyOf");
			cp = e;
		}

		try {
			Checkpoint.allOf(ch1, ch2, ch3).await(SYNC), yield *SYNCW();
		    assert(false, "Throw expected");
		} catch (e) {
			if (e.isAssertionFailure) throw e; // assersion, rethrow
			assert(f1, "Coroutine 1 finished at all");
			assert(f2, "Coroutine 2 finished at all");
			assert(f3, "Coroutine 3 finished at all");
		}

		assert(typeof (cp.errors.a) == "undefined", "Coroutine 2 result correctly dismissed");
		assert(cp.errors.b == "C1", "Coroutine 1 result got into valid slot");
		assert(typeof (cp.errors.c) == "undefined", "Coroutine 3 result correctly dismissed");
	},

	//
	// Promise interaction
	//

	"CRTK-SRC-H-1":
	function *(log, assert) {
		log("Test: Awaiter is a Promise");
		var aw1 = Awaiter(), t = false;
		aw1.then(function () { t = true; }, function() {});
		aw1();
		assert(t == false, "Awaiter callback code does not run immediately");
		// give it a chance to trigger
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t == true, "Awaiter resolved as a promise");
	},

	"CRTK-SRC-H-1-1":
	function *(log, assert) {
		log("Test: Awaiter is a Promise and can throw");
		var aw1 = Awaiter(), t = false;
		aw1.catch(function () { t = true; });
		aw1("error");
		assert(t == false, "Awaiter callback code does not run immediately");
		// give it a chance to trigger
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t == true, "Awaiter rejected as a promise");
	},

	"CRTK-SRC-H-1-2":
	function *(log, assert) {
		log("Test: Awaiter is a valid Promise");
		var aw1 = Awaiter(), t = false;
		// if it is consumed by Promise.all we can believe it's ok
		Promise.all([aw1]).then(function () { t = true; }, function() {});
		aw1();
		assert(t == false, "Awaiter callback code does not run immediately");
		// give it a chance to trigger
		setTimeout(SYNC, 100), yield *SYNCW();
		assert(t == true, "Awaiter resolved as a promise");
	},

	"CRTK-SRC-H-2":
	function *(log, assert) {
		log("Test: Promise is full Awaitable");
		var promise = new Promise(function(acc, rej) {
			setTimeout(function () { acc(150); }, 100);
		});
		// Checkpoint.allOf checks for sufficient Awaitable-ness
		var r = (Checkpoint.allOf(promise).await(SYNC), yield *SYNCW());
		assert(r.results[0] == 150, "Promise returned result as awaitable");

		promise.unawait(function() {}); // full = has unawait too
	},

	"CRTK-SRC-H-2-1":
	function *(log, assert) {
		log("Test: Promise is Awaitable and can reject");
		var promise = new Promise(function(acc, rej) {
			setTimeout(function () { rej(150); }, 100);
		});
		// Checkpoint.allOf checks for sufficient Awaitable-ness
		var cp = Checkpoint.allOf(promise);
		try {
			Checkpoint.allOf(promise).await(SYNC), yield *SYNCW();
		} catch (e) {
		}
		assert(cp.errors[0] == 150, "Promise rejected result as awaitable");
	},

	"CRTK-SRC-H-3":
	function *(log, assert) {
		log("Test: Promise has .done property");
		var promise = new Promise(function(acc, rej) {
			setTimeout(function () { acc(150); }, 100);
		});
		assert(!promise.done, "Promise .done not set before done");
		promise.await(SYNC), yield *SYNCW();
		assert(promise.done, "Promise .done set after done");
	},

	"CRTK-SRC-H-4":
	function *(log, assert) {
		log("Test: Promise has .result property");
		var promise = new Promise(function(acc, rej) {
			setTimeout(function () { acc(150); }, 100);
		});
		promise.await(SYNC), yield *SYNCW();
		assert(promise.result == 150, "Promise stored the result");
	},

	"CRTK-SRC-H-5":
	function *(log, assert) {
		log("Test: Promise has .error property");
		var promise = new Promise(function(acc, rej) {
			setTimeout(function () { rej(150); }, 100);
		});
		try {
			promise.await(SYNC), yield *SYNCW();
		} catch (e) {
		}
		assert(promise.error == 150, "Promise stored the error");
	},

	//
	// NowThen (all tests are NJS 7+)
	//
	"CRTK-SRC-I-1":
	function *(log, assert) {
		log("Test: await ((...NowThen.SYNC...), NowThen.SYNCW) is able to resume a coroutine");
		var t = false, c = start(async function () {
				var nt = NowThen();
				await (setTimeout(nt.SYNC, 1), nt.SYNCW);
				t = true;
				return 150;
			});
		setTimeout(SYNC, 100), yield *SYNCW(); // give it a chance
		c.await(SYNC), yield *SYNCW();
		assert(t, "The coroutine successfully progressed via nt.SYNC/SYNCW");
		assert(c.result == 150, "Valid value was passed to nt.SYNC");
	},

	"CRTK-SRC-I-2":
	function *(log, assert) {
		log("Test: NowThen.SYNC/SYNCW generated properly in complex expressions");
		function f1(callback, x) {
			start(async function() { callback (null, x); });
		}
		function f2(callback, x, y) {
			start(async function() { callback (null, x + y); });
		}
		var t;
		start (async function () {
			var nt = NowThen();
			t = await (
				f2(nt.SYNC, await(
						f1(nt.SYNC, "1"), nt.SYNCW
					), await(
						f1(nt.SYNC, "2"), nt.SYNCW
					)),
				nt.SYNCW);
			assert(t == "12", "The calls are properly performed");
		}).await(SYNC), yield *SYNCW();
		assert(t, "The coroutine successfully progressed via nt.SYNC/SYNCW");
	},

	"CRTK-SRC-I-3":
	function *(log, assert) {
		log("Test: await ((...NowThen.SYNCTL...), NowThen.SYNCW) is able to resume a coroutine");
		var t = false, c = start(async function () {
				var nt = NowThen();
				var result = await (function(callback) {
					setTimeout(function() {
						callback(100);
					}, 1);
				} (nt.SYNCTL), nt.SYNCW);
				t = true;
				return result;
			});
		setTimeout(SYNC, 100), yield *SYNCW(); // give it a chance
		c.await(SYNC), yield *SYNCW();
		assert(t, "The coroutine successfully progressed via nt.SYNCTL/SYNCW");
		assert(c.result == 100, "Valid value was passed to nt.SYNCTL");
	},

	"CRTK-SRC-I-4":
	function *(log, assert) {
		log("Test: NowThen timeslice feature works in generator coroutine");
		var failed = false, c = start(function *() {
			var nt = NowThen(),
				startAt = new Date().getTime(),
				lastYieldAt = startAt;
			for (; new Date().getTime() - startAt < 500;) {
				if (nt.timesliceUsedUp(10)) {
					nt.timesliceYield.await(SYNC), yield *SYNCW();
					lastYieldAt = new Date().getTime();
				}

				// OS scheduler break-in can add up to OS timeslice lag,
				// so making a reservation up to 100 ms
				if (new Date().getTime() - lastYieldAt > 110) {
					// timeslice detection wasn't properly detected,
					// or didn't properly yield in time
					failed = true;
					return;
				}
			}
		});

		c.await(SYNC), yield *SYNCW();
		assert(!failed, "Timeslice detected and yielded properly");
	},

	"CRTK-SRC-I-5":
	function *(log, assert) {
		log("Test: NowThen timeslice feature works in async func coroutine");
		var failed = false, c = start(async function () {
			var nt = NowThen(),
				startAt = new Date().getTime(),
				lastYieldAt = startAt;
			for (; new Date().getTime() - startAt < 500;) {
				if (nt.timesliceUsedUp(10)) {
					await(nt.timesliceYield);
					lastYieldAt = new Date().getTime();
				}

				// OS scheduler break-in can add up to OS timeslice lag,
				// so making a reservation up to 100 ms
				if (new Date().getTime() - lastYieldAt > 110) {
					// timeslice detection wasn't properly detected,
					// or didn't properly yield in time
					failed = true;
					return;
				}
			}
		});

		c.await(SYNC), yield *SYNCW();
		assert(!failed, "Timeslice detected and yielded properly");
	},

	"CRTK-SRC-I-6":
	function *(log, assert) {
		log("Test: NowThen TRY/aft/CATCH/FINALLY basic functionality");

		var nt = NowThen(), ag = new Array();
		nt.aft(() => ag.push("1"));

		try {
			nt.TRY;
			nt.aft(() => ag.push("2"));
			nt.aft(() => ag.push("3"));

			ag.push("4");

			for (var i = 0; i < 3; i++) {
				try {
					nt.TRY;
					nt.aft(() => ag.push("5"));
					ag.push("6");
					if (i == 1) throw "e";
				} finally {
					nt.FINALLY;
				}
			}
		} catch (e) {
			nt.CATCH;
			nt.aft(() => ag.push("7"));

			ag.push("8");
		} finally {
			nt.FINALLY;
		}

		ag.push("9");
		nt.FINALLY;

		assert(ag[0] == "4" &&
			ag[1] == "6" &&
			ag[2] == "5" &&
			ag[3] == "6" &&
			ag[4] == "5" &&
			ag[5] == "3" &&
			ag[6] == "2" &&
			ag[7] == "8" &&
			ag[8] == "7" &&
			ag[9] == "9" &&
			ag[10] == "1",
			"Valid agenda order");
	},

	"CRTK-SRC-I-7":
	function *(log, assert) {
		log("Test: NowThen TRY/aft/CATCH/FINALLY - leaking exception from dtor");

		var nt = NowThen(), ok = false;

		try {
			nt.TRY;
			try {
				nt.aft(() => { throw "e"; });
			} finally {
				nt.FINALLY;
			}

			assert(false, "Expected non-suppressed exception");
		} catch (e) {
			nt.FINALLY;
			assert(e == "e", "The expected exception is caught");
			ok = true;
		}

		assert(ok, "Test passed");
	},

	//
	// parameter error checks
	//
	"CRTK-SRC-J-1":
	function *(log, assert) {
		log("Test: start only accepts a function");
		try {
			start("stuff");
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-2":
	function *(log, assert) {
		log("Test: coroutine handle expects a function for await callback");
		try {
			var c = start(function *() {});
			c.await("stuff");
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-3":
	function *(log, assert) {
		log("Test: coroutine does not allow to await for itself");
		try {
			var c = start(function *() {
				c.await(SYNC), yield *SYNCW();
			});
			c.await(SYNC), yield *SYNCW();
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-4":
	function *(log, assert) {
		log("Test: new Awaiter() is not allowed");
		try {
			new Awaiter();
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-5":
	function *(log, assert) {
		log("Test: Awaiter expects a function for await callback");
		try {
			var c = Awaiter();
			c.await("stuff");
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-6":
	function *(log, assert) {
		log("Test: Checkpoint expects Awaitables");
		try {
			var c = Checkpoint.allOf("stuff");
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-7":
	function *(log, assert) {
		log("Test: new NowThen() is not allowed");
		try {
			new NowThen();
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-8":
	function *(log, assert) {
		log("Test: Checkpoint.allIn doesn't accept no-arg, non-array/dict or extra arg");
		try {
			Checkpoint.allIn();
			assert(false, "An error must be raised for no-arg");
		} catch (e) {
			assert(true, "The error raised correctly for no-arg");
		}

		try {
			Checkpoint.allIn("stuff");
			assert(false, "An error must be raised for non-array/dict");
		} catch (e) {
			assert(true, "The error raised correctly for non-array/dict");
		}

		try {
			Checkpoint.allIn([], 0);
			assert(false, "An error must be raised for extra arg");
		} catch (e) {
			assert(true, "The error raised correctly for extra arg");
		}

		try {
			Checkpoint.allIn([]).await(SYNC), yield *SYNCW();
			assert(true, "An error must not be raised for array");
		} catch (e) {
			assert(false, "The error raised incorrectly for array");
		}

		try {
			Checkpoint.allIn({}).await(SYNC), yield *SYNCW();
			assert(true, "An error must not be raised for dict");
		} catch (e) {
			assert(false, "The error raised incorrectly for dict");
		}
	},

	"CRTK-SRC-J-9":
	function *(log, assert) {
		log("Test: Checkpoint.anyIn doesn't accept no-arg, non-array/dict or extra arg");
		try {
			Checkpoint.anyIn();
			assert(false, "An error must be raised for no-arg");
		} catch (e) {
			assert(true, "The error raised correctly for no-arg");
		}

		try {
			Checkpoint.anyIn("stuff");
			assert(false, "An error must be raised for non-array/dict");
		} catch (e) {
			assert(true, "The error raised correctly for non-array/dict");
		}

		try {
			Checkpoint.anyIn([], 0);
			assert(false, "An error must be raised for extra arg");
		} catch (e) {
			assert(true, "The error raised correctly for extra arg");
		}

		try {
			Checkpoint.anyOf();
			Checkpoint.anyIn([]).await(SYNC), yield *SYNCW();
			assert(true, "An error must not be raised for array");
		} catch (e) {
			console.log(e);
			assert(false, "The error raised incorrectly for array");
		}

		try {
			Checkpoint.anyIn({}).await(SYNC), yield *SYNCW();
			assert(true, "An error must not be raised for dict");
		} catch (e) {
			assert(false, "The error raised incorrectly for dict");
		}
	},

	"CRTK-SRC-J-10":
	function *(log, assert) {
		log("Test: new Cancellation() is not allowed");
		try {
			new Cancellation();
			assert(false, "An error must be raised");
		} catch (e) {
			assert(true, "The error raised correctly");
		}
	},

	"CRTK-SRC-J-11":
	function *(log, assert) {
		log("Test: NowThen.aft only accepts functions");
		var nt = NowThen();
		try {
			nt.TRY;
			nt.aft("stuff");
			assert(false, "An error must be raised");
		} catch (e) {
			nt.FINALLY;
			assert(true, "The error raised correctly");
		}
	},

	//
	// issues
	//

	"CRTK-ISSUES-1":
	function *(log, assert) {
		log("Test: Awaiter() returns object with valid Function prototype");
		var aw = Awaiter();
		aw.apply(null, [null, 15]);
		var r = (aw.await(SYNC), yield *SYNCW());
		assert(r == 15, "Expected value delivered");
	},

	"CRTK-ISSUES-2":
	function *(log, assert) {
		log("Test: Checkpoint.anyOf unawaits the unused Awaitables");
		var awRaw = Awaiter(), callbacks = new Set();
		var aw = {
			await: function await(callback) {
				callbacks.add(callback);
				return awRaw.await(callback);
			},
			unawait: function unawait(callback) {
				callbacks.delete(callback);
				return awRaw.unawait(callback);
			},
			get done() {
				return awRaw.done;
			}
		};

		for (var i = 0; i < 10; i++) {
			Checkpoint.anyOf(aw, start(function *() {
				setTimeout(SYNC, 100), yield *SYNCW();
			})).await(SYNC), yield *SYNCW();
		}
		assert(callbacks.size == 0, "Unawait was applied to unused Awaitable-s");
	},

	"CRTK-ISSUES-3":
	function *(log, assert) {
		log("Test: cancellation message is delivered to cancellation callback");
		var got = false, c1 = start(function *() {
			setTimeout(SYNC, 100), yield *SYNCW.withCancel(
				function(msg) { got = msg; }
			);
		});
		c1.cancel("Y");
		try {
			c1.await(SYNC), yield *SYNCW();
			assert(false, "Expected a throw");
		} catch (e) {
		}
		assert(got == "Y", "Expected value passed from cancellation callback");
	},

	"CRTK-ISSUES-4":
	function *(log, assert) {
		log("Test: Checkpoint.done is set immediately for a null checkpoint");
		var cp = Checkpoint.allOf();
		assert(cp.done, "The .done is set correctly");
	},

	"CRTK-ISSUES-6":
	function *(log, assert) {
		log("Test: All ways of starting a coroutine work correctly, and coroutines return correctly");
		var cr, val, obj, thisCap, argsCap;

		// start with generator
		cr = start(function *(...args) {
			argsCap = args;
			setTimeout(SYNC, 10), yield *SYNCW();
			return 1;
		}, 2, 3);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 1, "coroutine started with generator returned expected value");
		assert(argsCap[0] == 2 && argsCap[1] == 3,
			"coroutine started with generator got expected arguments");

		// start method with generator
		cr = (obj = {
			m: function *(...args) {
				thisCap = this;
				argsCap = args;
				setTimeout(SYNC, 10), yield *SYNCW();
				return 101;
			}
		})[startMethod]("m", 102, 103);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 101, "coroutine method started with generator threw expected value");
		assert(argsCap[0] == 102 && argsCap[1] == 103,
			"coroutine method started with generator got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with generator got expected this");
		obj = null;

		// start with plain function
		cr = start(function (...args) {
			argsCap = args;
			return 201;
		}, 202, 203);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 201, "coroutine started with plain function returned expected value");
		assert(argsCap[0] == 202 && argsCap[1] == 203,
			"coroutine started with plain function got expected arguments");

		// start method with plain function
		cr = (obj = {
			m: function (...args) {
				thisCap = this;
				argsCap = args;
				return 301;
			}
		})[startMethod]("m", 302, 303);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 301, "coroutine method started with plain function returned expected value");
		assert(argsCap[0] == 302 && argsCap[1] == 303,
			"coroutine method started with plain function got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with plain function got expected this");
		obj = null;

		// start with async function
		cr = start(async function (...args) {
			var nt = NowThen();
			argsCap = args;
			await(setTimeout(nt.SYNC, 10), nt.SYNCW);
			return 401;
		}, 402, 403);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 401, "coroutine started with async function returned expected value");
		assert(argsCap[0] == 402 && argsCap[1] == 403,
			"coroutine started with generator got expected arguments");

		// start method with async function
		cr = (obj = {
			m: async function (...args) {
				var nt = NowThen();
				thisCap = this;
				argsCap = args;
				await(setTimeout(nt.SYNC, 10), nt.SYNCW);
				return 501;
			}
		})[startMethod]("m", 502, 503);
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 501, "coroutine method started with async function returned expected value");
		assert(argsCap[0] == 502 && argsCap[1] == 503,
			"coroutine method started with async function got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with async function got expected this");
		obj = null;

		// start with iterator
		cr = start(function *(...args) {
			argsCap = args;
			setTimeout(SYNC, 10), yield *SYNCW();
			return 601;
		}(602, 603));
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 601, "coroutine started with iterator returned expected value");
		assert(argsCap[0] == 602 && argsCap[1] == 603,
			"coroutine started with iterator got expected arguments");

		// start method with iterator
		cr = start((obj = {
			m: function *(...args) {
				thisCap = this;
				argsCap = args;
				setTimeout(SYNC, 10), yield *SYNCW();
				return 701;
			}
		}).m(702, 703));
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 701, "coroutine method started with iterator returned expected value");
		assert(argsCap[0] == 702 && argsCap[1] == 703,
			"coroutine method started with iterator got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with iterator got expected this");
		obj = null;

		// start with promise
		cr = start(async function (...args) {
			var nt = NowThen();
			argsCap = args;
			await(setTimeout(nt.SYNC, 10), nt.SYNCW);
			return 801;
		}(802, 803));
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 801, "coroutine started with promise returned expected value");
		assert(argsCap[0] == 802 && argsCap[1] == 803,
			"coroutine started with promise got expected arguments");

		// start method with promise
		cr = start ((obj = {
			m: async function (...args) {
				var nt = NowThen();
				thisCap = this;
				argsCap = args;
				await(setTimeout(nt.SYNC, 10), nt.SYNCW);
				return 901;
			}
		}).m(902, 903));
		val = (cr.await(SYNC), yield *SYNCW());
		assert(val == 901, "coroutine method started with promise returned expected value");
		assert(argsCap[0] == 902 && argsCap[1] == 903,
			"coroutine method started with promise got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with promise got expected this");
		obj = null;
	},

	"CRTK-ISSUES-6-1":
	function *(log, assert) {
		log("Test: All ways of starting a coroutine work correctly, and coroutines throw correctly");
		var cr, val = null, obj, thisCap, argsCap;

		// start with generator
		cr = start(function *(...args) {
			argsCap = args;
			setTimeout(SYNC, 10), yield *SYNCW();
			throw 1;
		}, 2, 3);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 1, "coroutine started with generator threw expected value");
		assert(argsCap[0] == 2 && argsCap[1] == 3,
			"coroutine started with generator got expected arguments");

		// start method with generator
		cr = (obj = {
			m: function *(...args) {
				thisCap = this;
				argsCap = args;
				setTimeout(SYNC, 10), yield *SYNCW();
				throw 101;
			}
		})[startMethod]("m", 102, 103);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 101, "coroutine method started with generator threw expected value");
		assert(argsCap[0] == 102 && argsCap[1] == 103,
			"coroutine method started with generator got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with generator got expected this");
		obj = null;

		// start with plain function
		cr = start(function (...args) {
			argsCap = args;
			throw 201;
		}, 202, 203);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 201, "coroutine started with plain function threw expected value");
		assert(argsCap[0] == 202 && argsCap[1] == 203,
			"coroutine started with plain function got expected arguments");

		// start method with plain function
		cr = (obj = {
			m: function (...args) {
				thisCap = this;
				argsCap = args;
				throw 301;
			}
		})[startMethod]("m", 302, 303);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 301, "coroutine method started with plain function threw expected value");
		assert(argsCap[0] == 302 && argsCap[1] == 303,
			"coroutine method started with plain function got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with plain function got expected this");
		obj = null;

		// start with async function
		cr = start(async function (...args) {
			var nt = NowThen();
			argsCap = args;
			await(setTimeout(nt.SYNC, 10), nt.SYNCW);
			throw 401;
		}, 402, 403);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 401, "coroutine started with async function threw expected value");
		assert(argsCap[0] == 402 && argsCap[1] == 403,
			"coroutine started with generator got expected arguments");

		// start method with async function
		cr = (obj = {
			m: async function (...args) {
				var nt = NowThen();
				thisCap = this;
				argsCap = args;
				await(setTimeout(nt.SYNC, 10), nt.SYNCW);
				throw 501;
			}
		})[startMethod]("m", 502, 503);
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 501, "coroutine method started with async function threw expected value");
		assert(argsCap[0] == 502 && argsCap[1] == 503,
			"coroutine method started with async function got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with async function got expected this");
		obj = null;

		// start with iterator
		cr = start(function *(...args) {
			argsCap = args;
			setTimeout(SYNC, 10), yield *SYNCW();
			throw 601;
		}(602, 603));
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 601, "coroutine started with iterator threw expected value");
		assert(argsCap[0] == 602 && argsCap[1] == 603,
			"coroutine started with iterator got expected arguments");

		// start method with iterator
		cr = start((obj = {
			m: function *(...args) {
				thisCap = this;
				argsCap = args;
				setTimeout(SYNC, 10), yield *SYNCW();
				throw 701;
			}
		}).m(702, 703));
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 701, "coroutine method started with iterator threw expected value");
		assert(argsCap[0] == 702 && argsCap[1] == 703,
			"coroutine method started with iterator got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with iterator got expected this");
		obj = null;

		// start with promise
		cr = start(async function (...args) {
			var nt = NowThen();
			argsCap = args;
			await(setTimeout(nt.SYNC, 10), nt.SYNCW);
			throw 801;
		}(802, 803));
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 801, "coroutine started with promise threw expected value");
		assert(argsCap[0] == 802 && argsCap[1] == 803,
			"coroutine started with promise got expected arguments");

		// start method with promise
		cr = start ((obj = {
			m: async function (...args) {
				var nt = NowThen();
				thisCap = this;
				argsCap = args;
				await(setTimeout(nt.SYNC, 10), nt.SYNCW);
				throw 901;
			}
		}).m(902, 903));
		try {
			cr.await(SYNC), yield *SYNCW();
		} catch (e) {
			val = e;
		}
		assert(val == 901, "coroutine method started with promise threw expected value");
		assert(argsCap[0] == 902 && argsCap[1] == 903,
			"coroutine method started with promise got expected arguments");
		assert(thisCap === obj,
			"coroutine method started with promise got expected this");
		obj = null;
	},
};

//
// test framework
// (it by itself will be an extra test by running all tests in async parallel)
//
var testResults = {};
start(function *() {
	console.log("---- Running tests... ----");
	var testAwaitables = new Array();
	for (let tcId in testCases) {
		// specify a test case ID on command line to run only it
		if (process.argv[2] && process.argv[2] != tcId) {
			continue;
		}
		if (tcId[0] != '*') {
			testResults[tcId] = false;
			let log = function(...msgs) {
					msgs[0] = `[${tcId}] ${msgs[0] || ''}`;
					console.log(...msgs);
				},
				assert = function(flag, description) {
					if(!flag) {
						log(`Assertion failed - ${description}`);
						var error = new Error(`Assertion failed - ${description}`);
						error.isAssertionFailure = true;
						throw error;
					} else {
						log(`Assertion passed - ${description}`);
					}
				}
			testAwaitables.push(start(function *() {
					try {
						yield *testCases[tcId](log, assert);
						testResults[tcId] = "passed";
						return `${tcId} passed`;
					} catch (e) {
						testResults[tcId] = e;
						throw e;
					}
				}
			));
		}
	}
	Checkpoint.allOf(testAwaitables).await(SYNC), yield *SYNCW();
}).await(function (err, result) {
	console.log("---- Tests run complete ----");
	if (err) { console.log(`${(err.errors && err.errors.length && (err.errors.length + " ")) || ""}FAILURE(S) ENCOUNTERED\n---\n` + err + "\n" + err.stack); }
	else { console.log("SUCCESS"); }

	console.log("---- Breakdown ----");
	for (var tcId in testResults) {
		console.log(`${tcId}: ${testResults[tcId].stack || testResults[tcId]}`);
	}
});

module.exports.test = "qq";


text:
class CallbackLocker

    ##
    # Indicates locker is locked.
    # @returns [Boolean] +true+ if it's, +false+ otherwise
    #

    @locked

    ##
    # Indicates, locker is just in synchronization state,
    # so stack of callbacks is evaluated just now.
    #
    # @returns [Boolean] +true+ if it's, +false+ otherwise
    #

    @syncing

    ##
    # Holds callback stack.
    # @return [Array]  array of callbacks
    #

    attr_accessor :stack
    @stack

    ##
    # Constructor.
    #

    def initialize
        @syncing = false
        @locked = false
        @stack = [ ]
    end

    ##
    # Locks the locker. Note, it's also alias for
    # {#try_lock} which is multiple pass-in so sets
    # lock although it's locked.
    #

    def lock
        @locked = true
    end

    alias :try_lock :lock
    alias :lock! :lock
    alias :try_lock! :try_lock

    ##
    # Unlocks the locker.
    #

    def unlock
        @locked = false
        self.eval!
    end

    alias :unlock! :unlock

    ##
    # Indicates, locker is locked.
    # @return [Boolean] +true+ if it's, +false+ otherwise
    #

    def locked?
        @locked
    end

    ##
    # Indicates, locker is unlocked.
    # @return [Boolean] +true+ if it's, +false+ otherwise
    #

    def unlocked?
        not self.locked?
    end

    ##
    # Synchronizes using the lock. Works by similiar
    # way as standard +Mutex#synchronize+.
    #
    # @yield if locker is unlocked the given callback
    #

    def synchronize(&block)
        if self.locked? or @syncing
            @stack << block
        else
            @syncing = true
            yield
            @syncing = false

            if not @stack.empty?
                self.eval!
            end
        end
    end

    ##
    # Evals the stack.
    #

    protected
    def eval!
        @syncing = true
        @stack.each { |b| b.call() }
        @stack.clear()
        @syncing = false
    end

end

redpajama_set_name: RedPajamaGithub


text:
<?php

/**
 * Test Drawing WKT for SimpleMappr
 *
 * @category  Class
 * @package   SimpleMappr
 * @author    David P. Shorthouse <davidpshorthouse@gmail.com>
 * @copyright 2010-2018 David P. Shorthouse
 * @license   MIT, https://github.com/dshorthouse/SimpleMappr/blob/master/LICENSE
 * @link      http://github.com/dshorthouse/SimpleMappr
 */
class DrawingsTest extends SimpleMapprFunctionalTestCase
{
    protected $title;
    protected $data;
    protected $color;
    protected $border;
    protected $hatch;

    /**
     * Set the form content based on integer
     *
     * @param integer $id The identifier
     *
     * @return void
     */
    private function _setLayerContent($id)
    {
        $this->title = $this->webDriver->findElement(WebDriverBy::name('wkt['.$id.'][title]'));
        $this->data = $this->webDriver->findElement(WebDriverBy::name('wkt['.$id.'][data]'));
        $this->color = $this->webDriver->findElement(WebDriverBy::name('wkt['.$id.'][color]'));
        $this->border = $this->webDriver->findElement(WebDriverBy::name('wkt['.$id.'][border]'));
        $this->hatch = $this->webDriver->findElement(WebDriverBy::name('wkt['.$id.'][hatch]'));

        $this->title->sendKeys('My Layer');
        $this->data->sendKeys('POLYGON((-70 63,-70 48,-106 48,-106 63,-70 63))');
        $this->color->clear()->sendKeys('10 10 10');
        $this->hatch->click();
    }

    /**
     * Test clear a point data layer.
     *
     * @return void
     */
    public function testClearDrawingLayer()
    {
        $link = $this->webDriver->findElement(WebDriverBy::linkText('Drawings'));
        $link->click();

        $layer_id = 0;
        $this->_setLayerContent($layer_id);

        $this->assertEquals($this->title->getAttribute('value'), 'My Layer');
        $this->assertEquals($this->data->getAttribute('value'), 'POLYGON((-70 63,-70 48,-106 48,-106 63,-70 63))');
        $this->assertEquals($this->color->getAttribute('value'), '10 10 10');
        $this->assertTrue($this->border->isSelected());
        $this->assertTrue($this->hatch->isSelected());

        $this->webDriver->findElements(WebDriverBy::xpath("//div[@id='fieldSetsWKT']//button[text()='Clear']"))[$layer_id]->click();

        $this->assertEquals($this->title->getAttribute('value'), '');
        $this->assertEquals($this->data->getAttribute('value'), '');
        $this->assertEquals($this->color->getAttribute('value'), '150 150 150');
        $this->assertFalse($this->border->isSelected());
        $this->assertFalse($this->hatch->isSelected());
    }

    /**
     * Test clear a point data layer from a newly added layer.
     *
     * @return void
     */
    public function testNewClearDrawingLayer()
    {
        $link = $this->webDriver->findElement(WebDriverBy::linkText('Drawings'));
        $link->click();
        $this->webDriver->findElement(WebDriverBy::xpath("//button[text()='Add a drawing']"))->click();
        sleep(3);

        $layer_id = 3;
        $this->_setLayerContent($layer_id);

        $this->assertEquals($this->title->getAttribute('value'), 'My Layer');
        $this->assertEquals($this->data->getAttribute('value'), 'POLYGON((-70 63,-70 48,-106 48,-106 63,-70 63))');
        $this->assertEquals($this->color->getAttribute('value'), '10 10 10');
        $this->assertTrue($this->border->isSelected());
        $this->assertTrue($this->hatch->isSelected());

        $this->webDriver->findElements(WebDriverBy::xpath("//div[@id='fieldSetsWKT']//button[text()='Clear']"))[$layer_id]->click();

        $this->assertEquals($this->title->getAttribute('value'), '');
        $this->assertEquals($this->data->getAttribute('value'), '');
        $this->assertEquals($this->color->getAttribute('value'), '150 150 150');
        $this->assertFalse($this->border->isSelected());
        $this->assertFalse($this->hatch->isSelected());
    }
}


text:
package lebah.util;

/**
 * @author Shamsul Bahrin Abd Mutalib
 * @version 1.01
 */
public class SelectListResource {

	public SelectListResource(){
		super();
	}

	public SelectList getYear(int yr1, int yr2) {
		SelectList select = new SelectList();
		for (int i = yr1; i < yr2 + 1; i++) {
			String yr = new Integer(i).toString();
			select.add(yr, yr);
		}
		return select;
	}
	public SelectList getMonth() {
		final String monthname[] =
		{"January","February","March","April","May",
		"June","July","August","September","October","November","December"};
		SelectList select = new SelectList();
		for (int i = 1; i < 13; i++) {
			select.add(monthname[i-1], monthname[i-1]);
		}
		return select;
	}
	public SelectList getDay() {
		SelectList select = new SelectList();
		for (int i = 1; i < 32; i++) {
			String s = new Integer(i).toString();
			select.add(s, s);
		}
		return select;
	}
	public SelectList getGender() {
		SelectList select = new SelectList();
		select.add("1", "MALE");
		select.add("2", "FEMALE");
		return select;
	}
	public SelectList getMaritalStatus() {
		SelectList select = new SelectList();
		select.add("1", "SINGLE");
		select.add("2", "MARRIED");
		select.add("3", "DIVORCED");
		return select;
	}
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>5. Access Control — Secure Networking Configuration Guide</title>

    <link rel="stylesheet" href="_static/vortex.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />

    <link rel="top" title="Secure Networking Configuration Guide" href="index.html" />
    <link rel="next" title="6. Access Control Configuration" href="accessctrlconfig.html" />
    <link rel="prev" title="4. Secure Networking Tutorial" href="securenettutorial.html" />

Navigation

          index

          next |

          previous |

Secure Networking Guide »

5. Access Control¶

The previous sections described how transport security is
achieved with the OpenSplice Secure Networking Module. This
section explains how access control is realized in OpenSplice
and gives a short introduction to the underlying concepts.

5.1. Overview¶

The OpenSplice Access Control Module is an optional, pluggable
service to the OpenSplice Secure Networking Module. It
complements the Secure Networking Module by offering different
types of access control modules that may be flexibly plugged in
(for example, mandatory access control, role-based access
control, etc.).

OpenSplice currently supports Mandatory Access Control (MAC)
based on the Bell-LaPadula/Biba model. Other
Access Control Modules may be available in a future release.

Access Control can be enabled in the OpenSplice secure
networking configuration (see
Secure Networking Configuration
). An external file containing the policy rules in
XML format can be referenced.

The following section, Mandatory Access Control, introduces
mandatory access control. MAC in OpenSplice
explains how Mandatory access control is realized in OpenSplice.

5.2. Mandatory Access Control¶

An access control policy defines whether a user (referred to as
a subject) is allowed to access an object.

The access control policy is centrally controlled when Mandatory
Access Control is in force. Users (subjects) may not override
the policy. For example when Mandatory Access Control is in
force users may not grant access to objects that would otherwise
be restricted.

Mandatory Access Control in OpenSplice ensures data
confidentiality as well as data integrity: data may only be
created and accessed by authorized parties. The control of
information flow is based on the Bell-LaPadula model. This
ensures that the information received via the network can only
be retrieved on nodes that:

are accredited for the secrecy level of this information, and

contain applications that have a need-to-know for the information.

Additionally, care is taken to preserve data integrity (based on
the Biba model) by:

preventing data modification by unauthorized parties

preventing unauthorized data modification by authorized parties

maintaining internal and external consistency

The following sections give a short introduction to the
Bell-LaPadula and Biba models. MAC in OpenSplice
explains how mandatory access control is realized in
OpenSplice.

5.2.1. Bell-LaPadula Confidentiality Model¶

The Bell-LaPadula Confidentiality model describes a set of
access control rules which use clearances for subjects (the
users) and classifications on objects (resources). The clearance
for a user and a classification of an object define a secrecy
level and a set of compartments. Secrecy levels are hierarchical
and range from the least sensitive, for example "Unclassified"
or "Public", to the most sensitive, for example "Top Secret".

Compartments are a non-hierarchical list of ID's (strings)
structuring information to enforce the 'need-to-know' principle.

The clearance of the subject is compared to the classification
of the object in order to determine if a subject is authorized
to access a certain object. The Bell-LaPadula model defines two
mandatory access control rules:

a subject at a given secrecy level may not read an object at
a higher secrecy level (no read-up).

a subject at a given secrecy level must not write to any
object at a lower secrecy level (no write-down).

In the Bell-LaPadula model, users can create content only at or
above their own secrecy level. For example, secret researchers
can create "Secret" or "Top-Secret" files, but may not create
"Public" files (no write-down). On the other hand, users can
view content only at or below their own secrecy level. For
example, secret researchers can view "Public" or "Secret" files,
but may not view "Top-Secret" files (no read-up).

Additionally, a subject must have a 'need-to-know' for the
object it wants to access; in other words, the set of
compartments contained in the user's clearance must be a subset
of the set of compartments contained in the object's
classification.

5.2.2. Biba Integrity Model¶

The Biba Integrity Model describes a set of access control rules
designed to ensure data integrity. Resources (objects) and users
(subjects) are grouped into ordered levels of integrity.

The Biba model defines two mandatory access control rules:

a subject at a given level of integrity may not read an
object at a lower integrity level (no read down).

a subject at a given level of integrity must not write to any
object at a higher level of integrity (no write up).

In the Biba model, users can only create content at or below
their own integrity level (no write up). On the other hand,
users can only view content at or above their own integrity
level (no read down).

5.3. Access Control in OpenSplice¶

In OpenSplice, access control is enforced on the network-level
for inter-node communication, in other words, the communication
between different nodes. One node (host) corresponds to one
user. When running multiple DDS applications on one host these
will all run under the same User ID.

There are two access control enforcement points:

for inbound traffic: when reading data from the network, the
following checks are carried out:

is the reader allowed to receive the data,

was the data published by a trusted node (in other words, was
the sender allowed to send the data)

for outbound traffic: when writing data to the network, the
following check is carried out:

is the user allowed to write data to the network

Note that access control is not enforced for intra-node
communication, in other words communication between DDS
applications running on the same node.

5.3.1. Objects to be Protected¶

One access control policy applies to one DDS Domain. The objects
to be protected by the access control policy in OpenSplice apply
to DDS topics and DDS partitions.

For example, a classification can be attached to a topic. This
may result in restricting access in a way that only users with a
matching clearance may use this topic for publication of data or
for subscription to data of this topic, respectively. The same
applies to partitions which are referenced by a resource element
of the access control policy.

5.3.2. Secure vs. Insecure¶

The 'secure' world is strictly separated from the 'insecure'
world in OpenSplice. If a resource does not have access control
information (for example a classification), then no access
control will be enforced for this resource. If a user has no
access control information (for example a clearance) they may
only access 'insecure' resources (resources that do not have
access control information like a classification). If a user has
access control information, then they may not access 'insecure'
resources that don't have access control information.

5.3.3. User Authentication¶

The system authenticates the user's identity.

OpenSplice currently supports SSL X.509 Certificate
Authentication. Other authentication mechanisms (such as user ID
- password authentication) may be available in a future release.

X.509 is a standard for digital certificates used by SSL.
Certificates include, among other things, information about the
identity of the certificate holder (in other words: the user).
The user authenticates to the system presenting a certificate.
The system accepts the user's certificate if it was issued by a
trusted authority. A list of trusted certificates can be defined
in the secure networking configuration (see
Element X509Authentication and
Element TrustedCertificates.

The user's identity is determined by a distinguished name (DN)
contained in the user's certificate. The system retrieves the
corresponding user from the access control policy (each user
entry in the policy defines the subject's DN) and applies the
defined access control information to this user.

5.4. MAC in OpenSplice¶

Mandatory Access Control (MAC) in Open Splice combines the
Bell-LaPadula and Biba models to ensure confidentiality and data
integrity. Each resource (object) has a classification which
comprises a secrecy level, an integrity level and a set of
compartments that this resource is intended for. Each user
(subject) has a clearance which comprises a secrecy level, an
integrity level and a set of compartments this user has a
'need-to-know' for.

In order to determine if a user is authorized to access a
certain resource, in other words, if they can publish a certain
topic or subscribe to a topic, the clearance of the user is
compared to the classification of the resource. This process
comprises the evaluation of the:

secrecy level

subscribing is permitted if the resource's secrecy level is
identical or lower than the user's secrecy level

publishing is permitted if the resource's secrecy level is
identical or higher than the user's secrecy level

integrity level

subscribing is permitted if the resource's integrity level is
identical or higher

publishing is permitted if the resource's integrity level is
identical or lower

need to know (compartment)

publish/subscribe is permitted if the user's set of
compartments is a subset of the resource's set of compartments

Access is only granted if all three parts of the user's
clearance (secrecy level, integrity level, and need-to-know) are
evaluated positively against the resource's classification.

The following section,
Access Control Configuration
describes access control policy configuration elements for MAC
in OpenSplice.

Table Of Contents

5. Access Control

5.1. Overview

5.2. Mandatory Access Control

5.2.1. Bell-LaPadula Confidentiality Model

5.2.2. Biba Integrity Model

5.3. Access Control in OpenSplice

5.3.1. Objects to be Protected

5.3.2. Secure vs. Insecure

5.3.3. User Authentication

5.4. MAC in OpenSplice

Previous topic

4. Secure Networking Tutorial

Next topic

6. Access Control Configuration

This Page

Show Source

Quick search

    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>

    Enter search terms or a module, class or function name.

Navigation

          index

          next |

          previous |

Secure Networking Guide »

        © Copyright 2018, ADLINK Technology Limited.


text:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Culebra" default="deprecated">
	<property file="ant.properties" />
	<loadproperties srcFile="project.properties" />

    <target name="deprecated">
        <echo message="NOTICE:" />
		<echo message="Jar file and monkeyrunner use are deprecated as of AndroidViewClient >= 4.0.0" />
    </target>

	<property name="versionRE" value="^\s*__version__\s*=\s*'(.*)'\s*$" />
	<loadfile srcfile="src/com/dtmilano/android/viewclient.py"
		property="avc.version">
		<filterchain>
			<linecontainsregexp>
				<regexp pattern="${versionRE}" />
			</linecontainsregexp>
			<tokenfilter>
				<replaceregex pattern="${versionRE}" replace="\1" />
			</tokenfilter>
			<striplinebreaks />
		</filterchain>
	</loadfile>

	<property name="avc.jar" value="bin/${avc.jarname}-${avc.version}.jar" />
	<target name="jar" depends="compile">
		<echo message="Creating ${avc.jarname} ${avc.version} jar ..." />
		<jar destfile="${avc.jar}">
			<fileset dir="src/" excludes="**/*.java" />
			<fileset dir="." includes="tools/*" />
			<fileset dir="bin/classes" />
			<manifest>
				<attribute name="Main-Class"
					value="com.dtmilano.android.viewclient.ViewClient" />
			</manifest>
		</jar>
	</target>

	<target name="clean">
		<delete dir="bin" />
	</target>

	<target name="compile">
		<mkdir dir="bin/classes" />
		<javac srcdir="src" destdir="bin/classes" />
	</target>

    <target name="install" depends="jar,doc-jar">
        <mkdir dir="${gdrive.bin.dest.dir}" />
        <copy file="${avc.jar}" todir="${gdrive.bin.dest.dir}" />
        <mkdir dir="${gdrive.doc.dest.dir}" />
        <copy file="${avc.doc.jar}" todir="${gdrive.doc.dest.dir}" />
    </target>

    <target name="doc" >
        <mkdir dir="docs" />
        <exec executable="epydoc">
            <arg value="--config=viewclient.epydoc" />
        </exec>
    </target>

	<property name="avc.doc.jar" value="bin/${avc.doc.jarname}-${avc.version}.jar" />
    <target name="doc-jar" depends="doc">
		<echo message="Creating ${avc.doc.jarname} ${avc.version} jar ..." />
		<jar destfile="${avc.doc.jar}">
            <fileset dir="docs/" />
        </jar>
    </target>
</project>


text:
/**
 * 	File contentente la classe ServiceStepListValidation
 *
 *	@file		ServiceStepListValidation.java
 *	@author		DeSQ
 *	@date		2014-05-12
 *	@version	1.0
 */

package com.sequenziatore.server.service.admin;

import java.util.List;

import com.sequenziatore.server.databaseutil.dao.DAOFactory;
import com.sequenziatore.server.databaseutil.dao.IDAOFactory;
import com.sequenziatore.server.databaseutil.util.HibernateUtil;
import com.sequenziatore.server.entity.DataCollection;
import com.sequenziatore.server.entity.IEntity;
import com.sequenziatore.server.entity.Process;
import com.sequenziatore.server.entity.Step;
import com.sequenziatore.server.entity.User;

import org.json.JSONArray;
import org.json.JSONObject;

import com.sequenziatore.server.service.interfaceservice.IService;

/**
 *	La classe ServiceStepListValidation offre il servizio di visualizzazione delle raccolte dati da validare.
 *
 *	@author 	DeSQ
 */
public class ServiceStepListValidation implements IService {

	/** Rappresenta l'interfaccia che garantisce l'accesso alle classi DAO per accedere al database. */
	private IDAOFactory iDAOFactory;

	/**
	 * Permette la ricerca delle raccolte dati da validare grazie alle informazioni acquisite dal front-end.
	 *
	 * @param entity contiene l'id dell'amministratore che fa la richiesta
	 * @return i dati delle collezioni da validare
	 */
	@Override
	public JSONObject serviceOperation(List<IEntity> entity) {
		JSONObject objectJson=new JSONObject();
		User user=(User)entity.get(0);
		iDAOFactory = new DAOFactory();
		try {
		    HibernateUtil.getSession().beginTransaction();
		    objectJson.put("Collections", this.order(user));
		    objectJson.put("Confirmation", "steps");
		    HibernateUtil.commitTransaction();
		} catch(Exception e) {
			return objectJson.put("Confirmation", "connectionError");
		}
	    return objectJson;
	}

	/**
	 * Permette di ordinare la lista degli step in base: idProcesso e livello.
	 *
	 * @param user contiene l'id dell'amministratore che fa la richiesta
	 * @return un JSONArray contenente gli step da validare ordinati
	 * @throws Exception
	 */
	private JSONArray order(User user) throws Exception{
		JSONArray arrayProcess= new JSONArray();
		List<Process> listProcess = iDAOFactory.createDAOManagementProcessAdmin().findDataCollectionsProcess(user);
		for(int i=0;i<listProcess.size();i++){
			JSONArray arrayLevel= new JSONArray();
			JSONObject process=new JSONObject();
			process.put("Name", listProcess.get(i).getName());
			process.put("List", arrayLevel);
			arrayProcess.put(process);
			List<Integer> listLevels =  iDAOFactory.createDAOManagementProcessAdmin().findDataCollectionsLevel(user, listProcess.get(i));
			for(int j=0;j<listLevels.size();j++){
				JSONObject level=new JSONObject();
				level.put("Name", listLevels.get(j));
				level.put("List", this.orderStep(user, listProcess.get(i), listLevels.get(j)));
				arrayLevel.put(level);
			}
		}
		return arrayProcess;
	}
	/**
	 * Permette di ordinare la lista degli step.
	 *
	 * @param user contiene l'id dell'amministratore che fa la richiesta
	 * @param process contiene l'id del processo
	 * @param level contiene il livello del processo
	 * @return un JSONArray contenente gli step da validare ordinati
	 * @throws Exception
	 */
	private JSONArray orderStep(User user, Process process, Integer level) throws Exception{
		List<Step> listIdStep = iDAOFactory.createDAOManagementProcessAdmin().findDataCollectionsStep(user, process, level);
		JSONArray arrayStep= new JSONArray();
		for(int k=0;k<listIdStep.size();k++){
			JSONArray arrayDataCollection= new JSONArray();
			JSONObject step=new JSONObject();
			step.put("Name",listIdStep.get(k).getDescription());
			step.put("List", arrayDataCollection);
			arrayStep.put(step);
			List<DataCollection> listDataCollections = iDAOFactory.createDAOManagementProcessAdmin().findDataCollectionIdStep(user, process, level, listIdStep.get(k).getIdStep());
			for(int z=0; z < listDataCollections.size(); z++){
				JSONObject objectJsonCollections=listDataCollections.get(z).toJSONObject();
				objectJsonCollections.put("Description",listDataCollections.get(z).getIdStep().getDescription());
				objectJsonCollections.put("CheckText",listDataCollections.get(z).getIdStep().getCheckText());
				objectJsonCollections.put("CheckLatitude",listDataCollections.get(z).getIdStep().getCheckLatitude());
				objectJsonCollections.put("CheckLongitude",listDataCollections.get(z).getIdStep().getCheckLongitude());
				objectJsonCollections.put("Level",listDataCollections.get(z).getIdStep().getLevel());
				objectJsonCollections.put("IdProcess",listDataCollections.get(z).getIdStep().getIdProcess().getIdProcess());
				objectJsonCollections.put("Name",listDataCollections.get(z).getIdStep().getIdProcess().getName());
				arrayDataCollection.put(objectJsonCollections);
			}
		}
		return arrayStep;
	}

}


text:
SUITE(Vibrato)
{
    struct VibratoData
    {
        VibratoData()  :
            m_pVibrato(0),
            m_ppfInputData(0),
            m_ppfOutputData(0),
            m_kiDataLength(35131),
            m_fMaxModWidth(.5F),
            m_iBlockLength(171),
            m_iNumChannels(3),
            m_fSampleRate(31271),
            m_fModWidth(.1F),
            m_fModFreq(1.F)
        {
            CVibrato::createInstance(m_pVibrato);
            m_pVibrato->initInstance(m_fMaxModWidth,m_fSampleRate,m_iNumChannels);

            m_ppfInputData = new float*[m_iNumChannels];
            m_ppfOutputData = new float*[m_iNumChannels];
            m_ppfInputTmp = new float*[m_iNumChannels];
            m_ppfOutputTmp = new float*[m_iNumChannels];
            for (int i = 0; i < m_iNumChannels; i++)
            {
                m_ppfInputData[i] = new float [m_kiDataLength];
                CSynthesis::generateSine(m_ppfInputData[i], 800, m_fSampleRate, m_kiDataLength, .6F, 0);
                m_ppfOutputData[i] = new float [m_kiDataLength];
                CVector::setZero(m_ppfOutputData[i], m_kiDataLength);
            }

        }

        ~VibratoData()
        {
            for (int i = 0; i < m_iNumChannels; i++)
            {
                delete [] m_ppfOutputData[i];
                delete [] m_ppfInputData[i];
            }
            delete [] m_ppfOutputTmp;
            delete [] m_ppfInputTmp;
            delete [] m_ppfOutputData;
            delete [] m_ppfInputData;

            CVibrato::destroyInstance(m_pVibrato);
        }

        void process ()
        {
            int iNumFramesRemaining = m_kiDataLength;
            while (iNumFramesRemaining > 0)
            {
                int iNumFrames = std::min(iNumFramesRemaining, m_iBlockLength);

                for (int c = 0; c < m_iNumChannels; c++)
                {
                    m_ppfInputTmp[c] = &m_ppfInputData[c][m_kiDataLength - iNumFramesRemaining];
                    m_ppfOutputTmp[c] = &m_ppfOutputData[c][m_kiDataLength - iNumFramesRemaining];
                }
                m_pVibrato->process(m_ppfInputTmp, m_ppfOutputTmp, iNumFrames);

                iNumFramesRemaining -= iNumFrames;
            }
        }

        CVibrato *m_pVibrato;
        float **m_ppfInputData,
            **m_ppfOutputData,
            **m_ppfInputTmp,
            **m_ppfOutputTmp;
        int m_kiDataLength;
        float m_fMaxModWidth;
        int m_iBlockLength;
        int m_iNumChannels;
        float m_fSampleRate;
        float m_fModWidth,
            m_fModFreq;

    };

    TEST_FIXTURE(VibratoData, VibModWidthZero)
    {
        m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 20);
        m_pVibrato->setParam(CVibrato::kParamModWidthInS, 0);

        process();

        int iDelay = CUtil::float2int<int>(m_fMaxModWidth*m_fSampleRate+1);
        for (int c = 0; c < m_iNumChannels; c++)
            CHECK_ARRAY_CLOSE(m_ppfInputData[c], &m_ppfOutputData[c][iDelay], m_kiDataLength-iDelay, 1e-3F);
    }

    TEST_FIXTURE(VibratoData, VibDc)
    {
        m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2);
        m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F);
        for (int c = 0; c < m_iNumChannels; c++)
        {
            CSynthesis::generateDc(m_ppfInputData[c], m_kiDataLength, (c+1)*.1F);
        }

        process();

        int iDelay = CUtil::float2int<int>(m_fMaxModWidth*m_fSampleRate+1);
        for (int c = 0; c < m_iNumChannels; c++)
            CHECK_ARRAY_CLOSE(m_ppfInputData[c], &m_ppfOutputData[c][iDelay], m_kiDataLength-iDelay, 1e-3F);
    }

    TEST_FIXTURE(VibratoData, VibVaryingBlocksize)
    {
        m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2);
        m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F);

        process();

        m_pVibrato->resetInstance();
        m_pVibrato->initInstance(m_fMaxModWidth,m_fSampleRate,m_iNumChannels);
        m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2);
        m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F);
        {
            int iNumFramesRemaining = m_kiDataLength;
            while (iNumFramesRemaining > 0)
            {

                int iNumFrames = std::min(iNumFramesRemaining, rand()/RAND_MAX*17000);

                for (int c = 0; c < m_iNumChannels; c++)
                {
                    m_ppfInputTmp[c] = &m_ppfInputData[c][m_kiDataLength - iNumFramesRemaining];
                }
                m_pVibrato->process(m_ppfInputTmp, m_ppfInputTmp, iNumFrames);

                iNumFramesRemaining -= iNumFrames;
            }
        }

        for (int c = 0; c < m_iNumChannels; c++)
            CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_kiDataLength, 1e-3);
    }

    TEST_FIXTURE(VibratoData, VibParamRange)
    {
        CHECK_EQUAL(Error_t::kFunctionInvalidArgsError, m_pVibrato->setParam(CVibrato::kParamModFreqInHz, -1));
        CHECK_EQUAL(Error_t::kFunctionInvalidArgsError, m_pVibrato->setParam(CVibrato::kParamModWidthInS, -0.001F));

        CHECK_EQUAL(Error_t::kFunctionInvalidArgsError, m_pVibrato->setParam(CVibrato::kParamModFreqInHz, m_fSampleRate));
        CHECK_EQUAL(Error_t::kFunctionInvalidArgsError, m_pVibrato->setParam(CVibrato::kParamModWidthInS, m_fMaxModWidth+.1F));
    }

    TEST_FIXTURE(VibratoData, VibZeroInput)
    {
        m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 20);
        m_pVibrato->setParam(CVibrato::kParamModWidthInS, 0);

        for (int c = 0; c < m_iNumChannels; c++)
            CVector::setZero(m_ppfInputData[c], m_kiDataLength);

        process();

        int iDelay = CUtil::float2int<int>(m_fMaxModWidth*m_fSampleRate+1);
        for (int c = 0; c < m_iNumChannels; c++)
            CHECK_ARRAY_CLOSE(m_ppfInputData[c], &m_ppfOutputData[c][iDelay], m_kiDataLength-iDelay, 1e-3F);
    }

}

#endif //WITH_TESTS


text:
<!DOCTYPE html>

<meta charset="utf-8">
</meta>
<meta content="width=device-width, initial-scale=1" name="viewport">
</meta>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
</link>
<link href="../../resources/stof-style.css" rel="stylesheet">
</link>

<button aria-expanded="false" class="navbar-toggle collapsed" data-target="#bs-example-navbar-collapse-1" data-toggle="collapse" type="button">

       Toggle navigation

</button>

      Bob Dylan Lyrics

        Downloads

        All Songs

        All Albums

        1960s

          Bob Dylan (1962)

          The Freewheelin' Bob Dylan (1963)

          The Times They Are A-Changin' (1964)

          Another Side of Bob Dylan (1964)

          Bringing It All Back Home (1965)

          Highway 61 Revisited (1965)

          Blonde on Blonde (1966))

          Bob Dylan's Greatest Hits (1967)

          John Wesley Harding (1967)

          Nashville Skyline (1969)

        1970s

          Self Portrait (1970)

          New Morning (1970)

          Bob Dylan's Greatest Hits, Vol. II (1971)

          Pat Garrett & Billy the Kid (1973)

          Dylan (1973)

          Planet Waves (1974)

          Before the Flood (1974)

          Blood on the Tracks (1975)

          The Basement Tapes (1975)

          Desire (1976)

          Hard Rain (1976)

          Street-Legal (1978)

          Bob Dylan at Budokan (1979)

          Slow Train Coming (1979)

        1980s

          Saved (1980)

          Shot of Love (1981)

          Infidels (1983)

          Real Live (1984)

          Empire Burlesque (1985)

          Biograph (1985)

          Knocked Out Loaded (1986)

          Down in the Groove (1988)

          Dylan & the Dead (1989)

          Oh Mercy (1989)

        1990s

          Under the Red Sky (1990)

          The Bootleg Series Volumes 1-3 (Rare & Unreleased) 1961-1991 (1991)

          Good As I Been to You (1992)

          World Gone Wrong (1993)

          Bob Dylan's Greatest Hits Volume 3 (1994)

          MTV Unplugged (1995)

          Time Out of Mind (1997)

          The Bootleg Series Vol. 4: Bob Dylan Live 1966, The "Royal Albert Hall" Concert (1998)

        2000s

          The Essential Bob Dylan (2000)

          Love and Theft (2001)

          The Bootleg Series Vol. 5: Bob Dylan Live 1975, The Rolling Thunder Revue (2002)

          The Bootleg Series Vol. 6: Bob Dylan Live 1964, Concert at Philharmonic Hall (2004)

          The Best of Bob Dylan (2005)

          Modern Times (2006)

          Together through Life (2009)

        2010s

          Tempest (2012)

<gcse:search>
<form class="navbar-form navbar-right" role="search">
</form>
</gcse:search>

      Big Yellow Taxi

       They paved paradise, they put up a parking lot,

       A pink hotel, a boutique, and a swinging, hot spot.

       Don't it always go to show

       You never know what you got till it's gone?

       They paved paradise, they put up a parking lot.

       They took all the trees, they put 'em in a tree museum,

       They charge the people a dollar and a half just to see 'em.

       Don't it always go to show

       You never know what you got till it's gone?

       They paved paradise, they put up a parking lot.

       Hey, farmer, farmer, put away that DDT,

       Give me spots on my apples, but leave me the birds and the bees please.

       Don't it always a-go to show

       You never know what you got till it's gone?

       They paved paradise, they put up a parking lot.

       Late last night I heard my screen door slam,

       A big, yellow bulldozer took away the house and land.

       Don't it always a-go to show

       You never know what you got till it's gone?

       They paved paradise, they put up a parking lot,

       They paved paradise, they put up a parking lot,

       They paved paradise, they put up a parking lot

       Paved paradise, they put up a parking lot.


text:
Login event flow
==
                      intro (MOTD)
                        |
      (new account) __login__  (existing account)
                   /         \
     create-account           password----------------------
        |                            |                     |
  change-password              choose-character      change-password
        |                            |
  create-player                      |
        |                            |
  player-name-check                  |
        |                            |
  finish-player                      |
        |__________________________done (add player to game world)
                                     |
                                   commands
             (command prompt, all player input after login goes through this event)