-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.ts
65 lines (56 loc) · 1011 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import test from 'ava';
import {Mixin} from './index';
test('apply mixins', t => {
// scaffold
class A {
constructor(n: number) {
t.is(++cnt, 1);
t.is(n, 0);
}
static a = 'A';
ap = 'a';
am() {
return this.ap;
}
}
class B {
constructor(n: number) {
t.is(++cnt, 2);
t.is(n, 0);
}
static b = 'B';
bp = 'b';
bm() {
return this.bp;
}
}
interface AB extends B, A {}
class X extends Mixin<AB>(B, A) {
constructor(n: number) {
super(n);
t.is(++cnt, 3);
t.is(n, 0);
}
static x = 'X';
xp = 'x';
xm() {
return this.xp;
}
}
//
let cnt = 0;
const x = new X(0);
t.is(++cnt, 4);
t.true(x instanceof A === false);
t.true(x instanceof B === false);
t.true(x instanceof X);
t.is(X['a'], 'A');
t.is(X['b'], 'B');
t.is(X.x, 'X');
t.is(x.ap, 'a');
t.is(x.bp, 'b');
t.is(x.xp, 'x');
t.is(x.am(), 'a');
t.is(x.bm(), 'b');
t.is(x.xm(), 'x');
});