1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+
9
+ import { EmitterVisitorContext } from '@angular/compiler/src/output/abstract_emitter' ;
10
+ import * as o from '@angular/compiler/src/output/output_ast' ;
11
+ import { JitEmitterVisitor } from '@angular/compiler/src/output/output_jit' ;
12
+
13
+ const anotherModuleUrl = 'somePackage/someOtherPath' ;
14
+
15
+ export function main ( ) {
16
+ describe ( 'Output JIT' , ( ) => {
17
+ describe ( 'regression' , ( ) => {
18
+ it ( 'should generate unique argument names' , ( ) => {
19
+ const externalIds = new Array ( 10 ) . fill ( 1 ) . map (
20
+ ( _ , index ) =>
21
+ new o . ExternalReference ( anotherModuleUrl , `id_${ index } _` , { name : `id_${ index } _` } ) ) ;
22
+ const externalIds1 = new Array ( 10 ) . fill ( 1 ) . map (
23
+ ( _ , index ) => new o . ExternalReference (
24
+ anotherModuleUrl , `id_${ index } _1` , { name : `id_${ index } _1` } ) ) ;
25
+ const ctx = EmitterVisitorContext . createRoot ( ) ;
26
+ const converter = new JitEmitterVisitor ( ) ;
27
+ converter . visitAllStatements (
28
+ [ o . literalArr ( [ ...externalIds1 , ...externalIds ] . map ( id => o . importExpr ( id ) ) ) . toStmt ( ) ] ,
29
+ ctx ) ;
30
+ const args = converter . getArgs ( ) ;
31
+ expect ( Object . keys ( args ) . length ) . toBe ( 20 ) ;
32
+ } ) ;
33
+ } ) ;
34
+ } )
35
+ }
0 commit comments