Created
March 24, 2011 18:00
-
-
Save DmitrySoshnikov/885534 to your computer and use it in GitHub Desktop.
Harmony modules import
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Test for module imports | |
* Tested in Narcissus | |
* by Dmitry Soshnikov | |
*/ | |
module M { | |
export var x = 10; | |
export var y = 20; | |
} | |
import M.x; | |
var y = M.y; | |
console.dir(Object.getOwnPropertyDescriptor(this, "x")); | |
// Result for "x" | |
// | |
// { | |
// [[Class]]: "Object", | |
// get: function, | |
// set: null, | |
// enumerable: true, | |
// configurable: true | |
// } | |
console.dir(Object.getOwnPropertyDescriptor(this, "y")); | |
// Result for "x" | |
// | |
// { | |
// [[Class]]: "Object", | |
// value: 20, | |
// writable: true, | |
// enumerable: true, | |
// configurable: true | |
// } | |
console.log(x); // 10 | |
console.log(y); // 20 | |
y = 100; // ok | |
x = 200; // SyntaxError: assignment to imported variable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment