Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
tests: Add an integration test for TypeScript overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Tavian Barnes committed Oct 1, 2019
1 parent ddc8bcb commit 9e32dc7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_build_ts/source/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,18 @@ class ClassDefinition {
anotherMethod() {

}
}

/**
* This is an overloaded method (1).
*/
overloaded(arg: number): number;

/**
* This is an overloaded method (2).
*/
overloaded(arg: string): string;

overloaded(arg: number | string): number | string {
return arg;
}
}
7 changes: 7 additions & 0 deletions tests/test_build_ts/test_build_ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ def test_autoclass_star_order(self):
pos_field = contents.index('ClassDefinition.field')
pos_method2 = contents.index('ClassDefinition.anotherMethod')
assert pos_method < pos_field < pos_method2, 'Methods and fields are not in right order in ' + contents

def test_overloads(self):
"""Make sure overloaded methods work."""
contents = self._file_contents('index')
pos_overloaded_1 = contents.index('overloaded method (1)')
pos_overloaded_2 = contents.index('overloaded method (2)')
assert pos_overloaded_1 < pos_overloaded_2, 'Method overloads are not in right order in ' + contents

0 comments on commit 9e32dc7

Please sign in to comment.