2017-07-17 13:52:42 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {EmitterVisitorContext} from '@angular/compiler/src/output/abstract_emitter';
|
|
|
|
import * as o from '@angular/compiler/src/output/output_ast';
|
|
|
|
import {JitEmitterVisitor} from '@angular/compiler/src/output/output_jit';
|
2017-08-16 12:00:03 -04:00
|
|
|
import {JitReflector} from '@angular/platform-browser-dynamic/src/compiler_reflector';
|
2017-07-17 13:52:42 -04:00
|
|
|
|
|
|
|
const anotherModuleUrl = 'somePackage/someOtherPath';
|
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('Output JIT', () => {
|
|
|
|
describe('regression', () => {
|
|
|
|
it('should generate unique argument names', () => {
|
|
|
|
const externalIds = new Array(10).fill(1).map(
|
|
|
|
(_, index) =>
|
|
|
|
new o.ExternalReference(anotherModuleUrl, `id_${index}_`, {name: `id_${index}_`}));
|
|
|
|
const externalIds1 = new Array(10).fill(1).map(
|
|
|
|
(_, index) => new o.ExternalReference(
|
|
|
|
anotherModuleUrl, `id_${index}_1`, {name: `id_${index}_1`}));
|
|
|
|
const ctx = EmitterVisitorContext.createRoot();
|
2017-08-16 12:00:03 -04:00
|
|
|
const converter = new JitEmitterVisitor(new JitReflector());
|
2017-07-17 13:52:42 -04:00
|
|
|
converter.visitAllStatements(
|
|
|
|
[o.literalArr([...externalIds1, ...externalIds].map(id => o.importExpr(id))).toStmt()],
|
|
|
|
ctx);
|
|
|
|
const args = converter.getArgs();
|
|
|
|
expect(Object.keys(args).length).toBe(20);
|
|
|
|
});
|
|
|
|
});
|
2017-07-27 19:13:16 -04:00
|
|
|
});
|
2017-07-17 13:52:42 -04:00
|
|
|
}
|