fix(transpiler): support arrow functions with complex body in named arguments
This commit is contained in:
parent
9f462c03f7
commit
44845839a6
|
@ -1,4 +1,4 @@
|
|||
import {describe, it, expect} from 'angular2/test_lib';
|
||||
import {describe, it, expect, iit} from 'angular2/test_lib';
|
||||
|
||||
var inc = x => x + 1;
|
||||
|
||||
|
@ -12,6 +12,10 @@ var max = (a, b) => {
|
|||
}
|
||||
};
|
||||
|
||||
var namedFn = function({fn}) {
|
||||
return fn();
|
||||
}
|
||||
|
||||
class LexicalThis {
|
||||
zero;
|
||||
|
||||
|
@ -30,6 +34,10 @@ export function main() {
|
|||
expect(inc(0)).toBe(1);
|
||||
});
|
||||
|
||||
it('should support implicit return in named arguments', function() {
|
||||
expect(namedFn({fn: () => 1})).toBe(1);
|
||||
});
|
||||
|
||||
it('should support object literal', function() {
|
||||
var o = objLiteral('val');
|
||||
expect(o['key']).toBe('val');
|
||||
|
@ -40,9 +48,16 @@ export function main() {
|
|||
expect(max(1, 0)).toBe(1);
|
||||
});
|
||||
|
||||
it('should support complex body in named arguments', function() {
|
||||
expect(namedFn({fn: () => {
|
||||
return 1;
|
||||
}})).toBe(1);
|
||||
});
|
||||
|
||||
it('should support lexical this', function() {
|
||||
var lthis = new LexicalThis();
|
||||
expect(lthis.getZero()).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ export class DartTransformer extends MultiTransformer {
|
|||
});
|
||||
};
|
||||
|
||||
append(NamedParamsTransformer);
|
||||
append(ArrowFunctionTransformer);
|
||||
append(NamedParamsTransformer);
|
||||
append(MultiVarTransformer);
|
||||
append(InstanceOfTransformer);
|
||||
append(StrictEqualityTransformer);
|
||||
|
|
Loading…
Reference in New Issue