Added tests for ix.d.ts

- added tests of all functions defined in ix.d.ts Enumerable
- minor fix in ix.d.ts
This commit is contained in:
Igor Oleinikov 2013-10-26 16:24:49 +04:00
parent af0f9c4bf5
commit 2b99487a28
2 changed files with 71 additions and 1 deletions

View File

@ -1,6 +1,7 @@
///<reference path="ix.d.ts"/>
var ec_ns = (a: number, b: string) => a.toString() == b; //equality comparer on number,string
var ec_ss = (a: string, b: string) => a == b; //equality comparer on string,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
@ -44,3 +45,72 @@ Ix.Enumerable.switchCase(() => "42", { "42": ax });
Ix.Enumerable.for(ax, a => ax);
Ix.Enumerable.forIn(ax, a => ax);
// instance
var bx: Ix.Enumerable<string>;
ax.isEmpty();
bx.minBy(b => b.length, c_nn);
bx.minBy(b => b.length);
bx.maxBy(b => b.length, c_nn);
bx.maxBy(b => b.length);
ax.share(ax => bx);
ax.share();
ax.publish(ax => bx);
ax.publish();
ax.memoize();
ax.do({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") });
ax.do(a => console.log(a), err => console.log(err), () => console.log("completed"));
ax.do(a => console.log(a), err => console.log(err));
ax.do((a: number) => console.log(a));
ax.doAction({ onNext: (a: number) => console.log(a), onError: err => console.log(err), onCompleted: () => console.log("completed") });
ax.doAction(a => console.log(a), err => console.log(err), () => console.log("completed"));
ax.doAction(a => console.log(a), err => console.log(err));
ax.doAction((a: number) => console.log(a));
ax.bufferWithCount(10, 20);
ax.bufferWithCount(10);
ax.ignoreElements();
bx.distinctBy(b => b.length, ec_nn);
bx.distinctBy(b => b.length);
bx.distinctUntilChanged(b => b.length, ec_nn);
bx.distinctUntilChanged(b => b.length);
bx.distinctUntilChanged();
bx.distinctUntilChanged(false, ec_ss);
ax.expand(a => ax);
ax.startWith(10, 20);
ax.scan(0, (acc, a) => acc + a);
ax.scan((acc, a) => acc + a);
ax.takeLast(10);
ax.skipLast(10);
ax.repeat(10);
ax.repeat();
ax.catch(ax, ax, ax);
ax.catchException(ax, ax, ax);
ax.catch(ax);
ax.catchException(ax);
ax.catch(err => ax);
ax.catchException(err => ax);
ax.finally(() => { });
ax.finallyDo(() => { });
ax.onErrorResumeNext(ax);
ax.retry(10);
ax.retry();

2
ix.js/ix.d.ts vendored
View File

@ -67,7 +67,7 @@ declare module Ix {
finally(finallyAction: () => void): Enumerable<T>;
finallyDo(finallyAction: () => void): Enumerable<T>;
onErrorResumeNext<T>(second: Enumerable<T>): Enumerable<T>;
onErrorResumeNext(second: Enumerable<T>): Enumerable<T>;
retry(retryCount?: number): Enumerable<T>;
}