Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kuno
committed
Feb 13, 2011
0 parents
commit 901c5b3
Showing
57 changed files
with
7,935 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This software is available under your choice of the following licenses: | ||
|
||
* MPL 1.1 or later: http://www.mozilla.org/MPL/ | ||
* GPL 2.0 or later: http://www.gnu.org/licenses/gpl.html | ||
* LGPL 2.1 or later: http://www.gnu.org/licenses/lgpl.html |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Narcissus | ||
|
||
Narcissus is a JavaScript interpreter written in pure JavaScript (i.e., a [meta-circular evaluator](http://en.wikipedia.org/wiki/Meta-circular_evaluator)), using the [SpiderMonkey](http://www.mozilla.org/js/spidermonkey/) engine. | ||
|
||
Originally a proof-of-concept by [Brendan Eich](http://brendaneich.com/), Narcissus is being revived as a test-bed for rapidly prototyping new language features for the JavaScript language (as well as the ECMAScript standard). | ||
|
||
# Documentation | ||
|
||
Documentation can be found on the [Narcissus wiki](https://github.com/mozilla/narcissus/wiki). | ||
|
||
# Contributors | ||
|
||
* Tom Austin | ||
* Brendan Eich | ||
* Andreas Gal | ||
* Shu-yu Guo | ||
* Dave Herman | ||
* Bruno Jouhier | ||
* Gregor Richards | ||
* Dimitris Vardoulakis | ||
* Patrick Walton |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
var Narcissus = require('../main.js'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This directory contains tests for experimental Harmony features. | ||
|
||
NOTE: Please don't fork this test suite without talking to me first! | ||
|
||
I purposefully created almost no test harness whatsoever -- just a stupid shell | ||
script that uses directory structure to figure out expected results. This is | ||
because: | ||
|
||
a) I don't want to write Yet Another Test Harness; and | ||
|
||
b) I'd like these tests to get eaten up by some other test suite eventually. | ||
|
||
So *please* talk to me first before forking; it's probably much better to | ||
adapt these tests directly. | ||
|
||
Dave Herman | ||
dherman@mozilla.com |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eval("var x = 42; export x;"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eval("xyzzx") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(function(x) { return eval("xyzzx") })("foo"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module A { | ||
import B.foo; | ||
var x = foo; | ||
} | ||
|
||
module B { | ||
export var foo = 12; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module M { | ||
export M.foo; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module M { | ||
export N.foo; | ||
} | ||
|
||
module N { | ||
export M.foo; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module M { | ||
export { foo: N.bar }; | ||
} | ||
|
||
module N { | ||
export { bar: M.foo }; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module M { | ||
export { foo: N.bar }; | ||
} | ||
|
||
module N { | ||
export { bar: O.baz }; | ||
} | ||
|
||
module O { | ||
export { baz: P.buz }; | ||
} | ||
|
||
module P { | ||
export { buz: M.foo }; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module M { export x } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eval("module M { export var foo = 42 }"); | ||
import M.foo; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eval("module M { export var foo = 42 }"); | ||
var x = M.foo; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module P { export module A { export var a = 12 } } | ||
|
||
module B = P.A | ||
|
||
B.a = 13; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var foo = someUnboundVariable; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
someUnboundVariable = 12; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/bin/sh | ||
|
||
HERE=`dirname $0` | ||
ROOT=$HERE/.. | ||
|
||
cd $ROOT | ||
|
||
FAILURES= | ||
|
||
################################################################################ | ||
|
||
echo Running harmony-tests/succeed... | ||
|
||
SUCCEED_PASS=0 | ||
SUCCEED_FAIL=0 | ||
|
||
for f in harmony-tests/succeed/*.js ; do | ||
./njs -H -f $f >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
SUCCEED_PASS=$(($SUCCEED_PASS + 1)) | ||
else | ||
SUCCEED_FAIL=$(($SUCCEED_FAIL + 1)) | ||
FAILURES="$FAILURES $f" | ||
fi | ||
done | ||
|
||
echo "==> $SUCCEED_PASS passed, $SUCCEED_FAIL failed." | ||
|
||
################################################################################ | ||
|
||
echo | ||
echo Running harmony-tests/fail-resolve... | ||
|
||
FAIL_RESOLVE_PASS=0 | ||
FAIL_RESOLVE_FAIL=0 | ||
|
||
for f in harmony-tests/fail-resolve/*.js ; do | ||
./njs -H -E "Narcissus.resolver.resolve(Narcissus.parser.parse(snarf('$f')),Narcissus.interpreter.globalStaticEnv)" >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
FAIL_RESOLVE_FAIL=$((FAIL_RESOLVE_FAIL + 1)) | ||
FAILURES="$FAILURES $f" | ||
else | ||
FAIL_RESOLVE_PASS=$((FAIL_RESOLVE_PASS + 1)) | ||
fi | ||
done | ||
|
||
echo "==> $FAIL_RESOLVE_PASS passed, $FAIL_RESOLVE_FAIL failed." | ||
|
||
################################################################################ | ||
|
||
echo | ||
echo Running harmony-tests/fail-execute... | ||
|
||
FAIL_EXECUTE_PASS=0 | ||
FAIL_EXECUTE_FAIL=0 | ||
|
||
for f in harmony-tests/fail-execute ; do | ||
./njs -H -f $f >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
FAIL_EXECUTE_FAIL=$(($FAIL_EXECUTE_FAIL + 1)) | ||
FAILURES="$FAILURES $f" | ||
else | ||
FAIL_EXECUTE_PASS=$(($FAIL_EXECUTE_PASS + 1)) | ||
fi | ||
done | ||
|
||
echo "==> $FAIL_EXECUTE_PASS passed, $FAIL_EXECUTE_FAIL failed." | ||
|
||
################################################################################ | ||
|
||
echo | ||
echo TOTAL: | ||
|
||
TOTAL_PASS=$(($SUCCEED_PASS + $FAIL_EXECUTE_PASS + $FAIL_RESOLVE_PASS)) | ||
TOTAL_FAIL=$(($SUCCEED_FAIL + $FAIL_EXECUTE_FAIL + $FAIL_RESOLVE_FAIL)) | ||
|
||
echo "==> $TOTAL_PASS passed, $TOTAL_FAIL failed." | ||
|
||
if [ $TOTAL_FAIL -gt 0 ]; then | ||
echo | ||
echo Failures: | ||
for f in $FAILURES ; do | ||
echo " $f" | ||
done | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module M { | ||
export var foo = 42; | ||
} | ||
|
||
assertEq(eval("import M.foo; foo"), 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module M { | ||
export var foo = "foo"; | ||
} | ||
|
||
assertEq(eval("module M { export var bar = 'bar' } import M.bar; bar"), "bar"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module M { | ||
export var foo = "foo"; | ||
} | ||
|
||
var foo = M.foo; | ||
var bar = eval("module M { export var bar = 'bar'; } M.bar"); | ||
|
||
assertEq(foo, "foo"); | ||
assertEq(bar, "bar"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var M1 = eval("module M { } M"); | ||
var M2 = eval("module M { } M"); | ||
|
||
assertEq(M1 === M2, false); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var foo = 42; | ||
|
||
var myfoo = eval("foo"); | ||
|
||
assertEq(foo, myfoo); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var foo = (function(x) { return eval("x") })("foo"); | ||
|
||
assertEq(foo, "foo"); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module M { | ||
import N.x; | ||
export x; | ||
} | ||
|
||
module N { | ||
var x = 42; | ||
export x; | ||
} | ||
|
||
assertEq(M.x, 42); | ||
assertEq(N.x, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module M { | ||
export var foo = 42; | ||
} | ||
|
||
assertEq(M.foo, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var global = this; | ||
|
||
assertEq("global" in global, true); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var saved; | ||
|
||
module M { | ||
saved = M; | ||
export var foo = 42; | ||
} | ||
|
||
assertEq("foo" in saved, true); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var saved; | ||
|
||
module M { | ||
export var foo = 42; | ||
var tmp = M; | ||
saved = tmp.foo; | ||
} | ||
|
||
assertEq(saved, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
assertEq(eval("module M { export var foo = 42 }").foo, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module P { | ||
module A { export var a = 12 } | ||
export A | ||
} | ||
|
||
module B = P.A | ||
|
||
assertEq(B.a, 12); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module P { | ||
module A { export var a = 12 } | ||
export A | ||
} | ||
|
||
module B = P.A, C = P.A, D = P.A; | ||
|
||
assertEq(B.a, 12); | ||
assertEq(C.a, 12); | ||
assertEq(D.a, 12); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module M { | ||
export var foo = 42; | ||
export module N { | ||
module M; | ||
export var foo = M.foo | ||
} | ||
} | ||
|
||
assertEq(M.foo, M.N.foo); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var saved; | ||
|
||
module M { | ||
saved = this; | ||
export var foo = 42; | ||
} | ||
|
||
assertEq("foo" in saved, true); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module M { | ||
export module N { | ||
export var foo = 42; | ||
export var bar = "hello world"; | ||
} | ||
} | ||
|
||
module Q { | ||
export { | ||
foo: M.N.bar, | ||
bar: M.N.foo | ||
} | ||
} | ||
|
||
assertEq(Q.foo, "hello world"); | ||
assertEq(Q.bar, 42); | ||
assertEq(Q.foo, M.N.bar); | ||
assertEq(Q.bar, M.N.foo); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module M { | ||
export module N { | ||
export var foo = 42; | ||
export var bar = "hello world"; | ||
} | ||
} | ||
|
||
module Q { | ||
module MN = M.N; | ||
export { | ||
foo: MN.bar, | ||
bar: MN.foo | ||
} | ||
} | ||
|
||
assertEq(Q.foo, "hello world"); | ||
assertEq(Q.bar, 42); | ||
assertEq(Q.foo, M.N.bar); | ||
assertEq(Q.bar, M.N.foo); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var saved = M; | ||
|
||
module M { | ||
export var foo = 42; | ||
} | ||
|
||
assertEq(saved.foo, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var saved = M.N; | ||
|
||
module M { | ||
export module N { | ||
export var foo = 42; | ||
} | ||
} | ||
|
||
assertEq(saved.foo, 42); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var saved; | ||
|
||
module M { | ||
module N { | ||
saved = M.O.P; | ||
} | ||
export module O { | ||
export module P { | ||
export var foo = 42; | ||
} | ||
} | ||
} | ||
|
||
assertEq(saved.foo, 42); |
Oops, something went wrong.