Skip to content

Commit 5974e27

Browse files
committed
Some more tests
1 parent 046a28c commit 5974e27

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

src/TSHelper.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,14 @@ export class TSHelper {
9797
public static isTupleReturnFunction(type: ts.Type, checker: ts.TypeChecker): boolean {
9898
return type.symbol
9999
&& ((type.symbol.flags & ts.SymbolFlags.Function) !== 0)
100-
&& this.hasCustomDecorator(type, checker, "!TupleReturn");
100+
&& this.hasCustomDecorator(type, checker, "!TupleReturn");
101101
}
102102

103103
public static hasCustomDecorator(type: ts.Type, checker: ts.TypeChecker, decorator: string): boolean {
104-
if (type.symbol) {
105-
const comment = type.symbol.getDocumentationComment(checker);
106-
const decorators =
107-
comment.filter((_) => _.kind === "text").map((_) => _.text.trim()).filter((_) => _[0] === "!");
108-
return decorators.indexOf(decorator) > -1;
109-
}
110-
return false;
104+
const comment = type.symbol.getDocumentationComment(checker);
105+
const decorators =
106+
comment.filter((_) => _.kind === "text").map((_) => _.text.trim()).filter((_) => _[0] === "!");
107+
return decorators.indexOf(decorator) > -1;
111108
}
112109

113110
// Search up until finding a node satisfying the callback
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
local test1 = 10
2+
3+
local test2 = 10

test/translation/ts/typeAssert.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const test1 = <number> 10;
2+
const test2 = 10 as number;

test/unit/enum.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Expect, Test, TestCase } from "alsatian";
2+
import * as util from "../src/util"
3+
4+
export class EnumTests {
5+
@Test("Unsuported enum")
6+
public unsuportedEnum() {
7+
// Transpile & Assert
8+
Expect(() => {
9+
let lua = util.transpileString(
10+
`enum TestEnum {
11+
val1 = "test",
12+
val2 = "ok",
13+
val3 = "bye"
14+
}`
15+
);
16+
}).toThrowError(Error, "Only numeric initializers allowed for enums.");
17+
}
18+
}

0 commit comments

Comments
 (0)