OLD | NEW |
1 /// <reference path="../typings/mocha/mocha.d.ts"/> | 1 /// <reference path="../typings/mocha/mocha.d.ts"/> |
2 import * as fs from 'fs'; | |
3 | 2 |
4 import {expectTranslate, FAKE_MAIN} from './test_support'; | 3 import {expectTranslate, FAKE_MAIN} from './test_support'; |
5 | 4 |
6 let es6RuntimeDeclarations = ` | 5 let es6RuntimeDeclarations = ` |
7 interface Iterable<T> {} | 6 interface Iterable<T> {} |
8 interface Symbol {} | 7 interface Symbol {} |
9 interface Map<K, V> { | 8 interface Map<K, V> { |
10 get(key: K): V; | 9 get(key: K): V; |
11 has(key: K): boolean; | 10 has(key: K): boolean; |
12 set(key: K, value: V): Map<K, V>; | 11 set(key: K, value: V): Map<K, V>; |
13 size: number; | 12 size: number; |
14 delete(key: K): boolean; | 13 delete(key: K): boolean; |
15 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?
: any): void; | 14 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?
: any): void; |
16 } | 15 } |
17 interface Array<T> { | 16 interface Array<T> { |
18 find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisA
rg?: any): T; | 17 find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisA
rg?: any): T; |
19 } | 18 } |
20 declare var Map: { | 19 declare var Map: { |
21 new<K, V>(): Map<any, any>; | 20 new<K, V>(): Map<any, any>; |
22 prototype: Map<any, any>; | 21 prototype: Map<any, any>; |
23 }; | 22 }; |
24 declare var Symbol; | 23 declare var Symbol; |
25 `; | 24 `; |
26 | 25 |
27 | 26 |
28 function getSources(str: string): {[k: string]: string} { | 27 function getSources(str: string): {[k: string]: string} { |
29 let srcs: {[k: string]: string} = { | 28 let srcs: {[k: string]: string} = { |
30 'some/path/to/typings/es6-shim/es6-shim': es6RuntimeDeclarations, | 29 'some/path/to/typings/es6-shim/es6-shim': es6RuntimeDeclarations, |
31 'some/path/to/typings/es6-promise/es6-promise.d.ts': | |
32 fs.readFileSync('typings/es6-promise/es6-promise.d.ts', 'utf-8'), | |
33 'other/file.ts': ` | 30 'other/file.ts': ` |
34 export class X { | 31 export class X { |
35 map(x: number): string { return String(x); } | 32 map(x: number): string { return String(x); } |
36 static get(m: any, k: string): number { return m[k]; } | 33 static get(m: any, k: string): number { return m[k]; } |
37 } | 34 } |
38 export class Promise {} | 35 export class Promise {} |
39 `, | 36 `, |
40 }; | 37 }; |
41 srcs[FAKE_MAIN] = str; | 38 srcs[FAKE_MAIN] = str; |
42 return srcs; | 39 return srcs; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 'let x:X;') | 126 'let x:X;') |
130 .to.equal(`import "file.dart" show X; | 127 .to.equal(`import "file.dart" show X; |
131 | 128 |
132 @JS() | 129 @JS() |
133 external X get x; | 130 external X get x; |
134 @JS() | 131 @JS() |
135 external set x(X v);`); | 132 external set x(X v);`); |
136 }); | 133 }); |
137 }); | 134 }); |
138 }); | 135 }); |
OLD | NEW |