From af0f9c4bf5af0178be1b881b97f81351c3545560 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Sat, 26 Oct 2013 14:58:43 +0400 Subject: [PATCH] Added tests for ix.d.ts Tested all functions defined in ix.d.ts in EnumerableStatic --- ix.js/ix-tests.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ix.js/ix-tests.ts diff --git a/ix.js/ix-tests.ts b/ix.js/ix-tests.ts new file mode 100644 index 000000000..dc44f1589 --- /dev/null +++ b/ix.js/ix-tests.ts @@ -0,0 +1,46 @@ +/// + +var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string +var ec_nn = (a: number, b: number) => a === b; //equality comparer on number,number +var c_nn = (a: number, b: number) => a - b; //comparer on number,number + +// static + +Ix.Enumerable.throw(new Error("error")); +Ix.Enumerable.throwException(new Error("error")); + +var ax = Ix.Enumerable.generate(-100, a => a < 100, a=> a + 10, a=> a * 2); + +Ix.Enumerable.defer(() => ax); + +Ix.Enumerable.using(() => ax.getEnumerator(), e => Ix.Enumerable.return(e.getCurrent())); + +Ix.Enumerable.catch(ax, ax, ax); +Ix.Enumerable.catchException(ax, ax, ax); +Ix.Enumerable.catch(); +Ix.Enumerable.catchException(); + +Ix.Enumerable.onErrorResumeNext(ax, ax, ax); +Ix.Enumerable.onErrorResumeNext(); + +Ix.Enumerable.while(x => x.count() > 0, ax); +Ix.Enumerable.whileDo(x => x.count() > 0, ax); + +Ix.Enumerable.if(() => true, ax, ax); +Ix.Enumerable.ifThen(() => true, ax, ax); +Ix.Enumerable.if(() => true, ax); +Ix.Enumerable.ifThen(() => true, ax); + +Ix.Enumerable.doWhile(ax, x => x.count() > 0); + +Ix.Enumerable.case(() => 42, { 42: ax }, ax); +Ix.Enumerable.switchCase(() => 42, { 42: ax }, ax); +Ix.Enumerable.case(() => 42, { 42: ax }); +Ix.Enumerable.switchCase(() => 42, { 42: ax }); +Ix.Enumerable.case(() => "42", { "42": ax }, ax); +Ix.Enumerable.switchCase(() => "42", { "42": ax }, ax); +Ix.Enumerable.case(() => "42", { "42": ax }); +Ix.Enumerable.switchCase(() => "42", { "42": ax }); + +Ix.Enumerable.for(ax, a => ax); +Ix.Enumerable.forIn(ax, a => ax);