-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #546 - Add typescript support to the wisdom maven plugin.
- Loading branch information
1 parent
46e7af1
commit 51ece68
Showing
15 changed files
with
232 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core/wisdom-maven-plugin/src/test/resources/typescript/math/demos.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
///<reference path="./interfaces.d.ts" /> | ||
|
||
import { MathDemo } from "./impl/math_demo"; | ||
|
||
var math = new MathDemo(); | ||
console.log(math.pow(2, 2)); | ||
console.log(math.PI); |
64 changes: 64 additions & 0 deletions
64
core/wisdom-maven-plugin/src/test/resources/typescript/math/impl/math_demo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
///<reference path="./../interfaces.d.ts" /> | ||
|
||
class MathDemo implements MathInterface{ | ||
public PI : number; | ||
|
||
constructor() { | ||
this.PI = 3.14159265359; | ||
} | ||
|
||
// used to showcase how to test a sync function | ||
public pow(base: number, exponent: number) { | ||
var result = base; | ||
for(var i = 1; i < exponent; i++){ | ||
result = result * base; | ||
} | ||
return result; | ||
} | ||
|
||
// used to show case how to test async code with done() | ||
public powAsync(base: number, exponent: number, cb : (result : number) => void) { | ||
var result = this.pow(base, exponent); | ||
cb(result); | ||
} | ||
|
||
// simulate slow > 40ms | ||
public powAsyncSlow(base: number, exponent: number, cb : (result : number) => void) { | ||
setTimeout(() => { | ||
var result = this.pow(base, exponent); | ||
cb(result); | ||
}, 45); | ||
} | ||
|
||
// simulate reelly slow function > 100ms | ||
public powAsyncReallySlow(base: number, exponent: number, cb : (result : number) => void) { | ||
var result = base ^ exponent; | ||
setTimeout(() => { | ||
var result = this.pow(base, exponent); | ||
cb(result); | ||
}, 101); | ||
} | ||
|
||
// simulate too slow > 2000ms (breaks build) | ||
public powAsyncTooSlow(base: number, exponent: number, cb : (result : number) => void) { | ||
var result = base ^ exponent; | ||
setTimeout(() => { | ||
var result = this.pow(base, exponent); | ||
cb(result); | ||
}, 2001); | ||
} | ||
|
||
// used to showcase how to assert that an error is thrown | ||
public bad(foo : any) { | ||
if(foo == null){ | ||
throw new Error("Error!"); | ||
} | ||
else { | ||
//... | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
export { MathDemo }; |
9 changes: 9 additions & 0 deletions
9
core/wisdom-maven-plugin/src/test/resources/typescript/math/interfaces.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
interface MathInterface { | ||
PI : number; | ||
pow(base: number, exponent: number); | ||
powAsync(base: number, exponent: number, cb : (result : number) => void); | ||
powAsyncSlow(base: number, exponent: number, cb : (result : number) => void); | ||
powAsyncReallySlow(base: number, exponent: number, cb : (result : number) => void); | ||
powAsyncTooSlow(base: number, exponent: number, cb : (result : number) => void); | ||
bad(foo : any) : void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...n-it/src/it/projects/asset-processing-with-fileset/src/main/resources/assets/ts/Animal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Animal { | ||
constructor(public name: string) { } | ||
move(meters: number) { | ||
alert(this.name + " moved " + meters + "m."); | ||
} | ||
} | ||
|
||
class Snake extends Animal { | ||
constructor(name: string) { super(name); } | ||
move() { | ||
alert("Slithering..."); | ||
super.move(5); | ||
} | ||
} | ||
|
||
class Horse extends Animal { | ||
constructor(name: string) { super(name); } | ||
move() { | ||
alert("Galloping..."); | ||
super.move(45); | ||
} | ||
} | ||
|
||
var sam = new Snake("Sammy the Python"); | ||
var tom: Animal = new Horse("Tommy the Palomino"); | ||
|
||
sam.move(); | ||
tom.move(34); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.