@@ -379,6 +379,19 @@ export class FunctionTests {
379379 Expect ( result ) . toBe ( "foobar" ) ;
380380 }
381381
382+ @Test ( "Element access call no args" )
383+ public elementAccessCallNoArgs ( ) : void {
384+ const code = `class C {
385+ prop = "bar";
386+ method() { return this.prop; }
387+ }
388+ const c = new C();
389+ return c['method']();
390+ ` ;
391+ const result = util . transpileAndExecute ( code ) ;
392+ Expect ( result ) . toBe ( "bar" ) ;
393+ }
394+
382395 @Test ( "Complex element access call" )
383396 public elementAccessCallComplex ( ) : void {
384397 const code = `class C {
@@ -392,6 +405,19 @@ export class FunctionTests {
392405 Expect ( result ) . toBe ( "foobar" ) ;
393406 }
394407
408+ @Test ( "Complex element access call no args" )
409+ public elementAccessCallComplexNoArgs ( ) : void {
410+ const code = `class C {
411+ prop = "bar";
412+ method() { return this.prop; }
413+ }
414+ function getC() { return new C(); }
415+ return getC()['method']();
416+ ` ;
417+ const result = util . transpileAndExecute ( code ) ;
418+ Expect ( result ) . toBe ( "bar" ) ;
419+ }
420+
395421 @Test ( "Complex element access call statement" )
396422 public elementAccessCallComplexStatement ( ) : void {
397423 const code = `let foo: string;
@@ -475,4 +501,14 @@ export class FunctionTests {
475501 export const result = bar(7);` ;
476502 Expect ( util . transpileExecuteAndReturnExport ( code , "result" ) ) . toBe ( 7 ) ;
477503 }
504+
505+ @Test ( "Function using global as this" )
506+ public functionUsingGlobalAsThis ( ) : void {
507+ const code =
508+ `var foo = "foo";
509+ function bar(this: any) {
510+ return this.foo;
511+ }` ;
512+ Expect ( util . transpileAndExecute ( "return foo;" , undefined , undefined , code ) ) . toBe ( "foo" ) ;
513+ }
478514}
0 commit comments