mirror of
				https://github.com/tc39/test262.git
				synced 2025-11-04 05:33:50 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// Copyright (C) 2018 Leo Balter. All rights reserved.
 | 
						|
// This code is governed by the BSD license found in the LICENSE file.
 | 
						|
/*---
 | 
						|
description: >
 | 
						|
    Dynamic Import receives an AssignmentExpression (Object properties from MemberExpressions)
 | 
						|
esid: prod-ImportCall
 | 
						|
info: |
 | 
						|
    ImportCall [Yield]:
 | 
						|
        import ( AssignmentExpression[+In, ?Yield] )
 | 
						|
 | 
						|
    AssignmentExpression[In, Yield, Await]:
 | 
						|
        ConditionalExpression[?In, ?Yield, ?Await]
 | 
						|
        [+Yield]YieldExpression[?In, ?Await]
 | 
						|
        ArrowFunction[?In, ?Yield, ?Await]
 | 
						|
        AsyncArrowFunction[?In, ?Yield, ?Await]
 | 
						|
        LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await]
 | 
						|
        LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await]
 | 
						|
flags: [async]
 | 
						|
features: [dynamic-import]
 | 
						|
---*/
 | 
						|
 | 
						|
const obj = {
 | 
						|
    a: './module-code_FIXTURE.js',
 | 
						|
    b: './module-code-other_FIXTURE.js'
 | 
						|
}
 | 
						|
 | 
						|
async function fn() {
 | 
						|
    // MemberExpression [ Expression ]
 | 
						|
    const ns1 = await import(obj['a']);
 | 
						|
 | 
						|
    assert.sameValue(ns1.local1, 'Test262');
 | 
						|
    assert.sameValue(ns1.default, 42);
 | 
						|
 | 
						|
    // MemberExpression . IdentifierName
 | 
						|
    const ns2 = await import(obj.b);
 | 
						|
 | 
						|
    assert.sameValue(ns2.local1, 'one six one two');
 | 
						|
    assert.sameValue(ns2.default, 1612);
 | 
						|
}
 | 
						|
 | 
						|
fn().then($DONE, $DONE).catch($DONE);
 |