Skip to content

Commit

Permalink
removed narcissus.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kuno committed Feb 13, 2011
0 parents commit 901c5b3
Show file tree
Hide file tree
Showing 57 changed files with 7,935 additions and 0 deletions.
5 changes: 5 additions & 0 deletions LICENSE
@@ -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
21 changes: 21 additions & 0 deletions README.md
@@ -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
3 changes: 3 additions & 0 deletions bin/njs.js
@@ -0,0 +1,3 @@
#!/usr/bin/env node

var Narcissus = require('../main.js');
17 changes: 17 additions & 0 deletions harmony-tests/README.txt
@@ -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
1 change: 1 addition & 0 deletions harmony-tests/fail-execute/eval-export.js
@@ -0,0 +1 @@
eval("var x = 42; export x;");
1 change: 1 addition & 0 deletions harmony-tests/fail-execute/eval-resolve1.js
@@ -0,0 +1 @@
eval("xyzzx")
1 change: 1 addition & 0 deletions harmony-tests/fail-execute/eval-resolve2.js
@@ -0,0 +1 @@
(function(x) { return eval("xyzzx") })("foo");
8 changes: 8 additions & 0 deletions harmony-tests/fail-execute/module-uninit-read.js
@@ -0,0 +1,8 @@
module A {
import B.foo;
var x = foo;
}

module B {
export var foo = 12;
}
3 changes: 3 additions & 0 deletions harmony-tests/fail-resolve/export-cycle1.js
@@ -0,0 +1,3 @@
module M {
export M.foo;
}
7 changes: 7 additions & 0 deletions harmony-tests/fail-resolve/export-cycle2.js
@@ -0,0 +1,7 @@
module M {
export N.foo;
}

module N {
export M.foo;
}
7 changes: 7 additions & 0 deletions harmony-tests/fail-resolve/export-cycle3.js
@@ -0,0 +1,7 @@
module M {
export { foo: N.bar };
}

module N {
export { bar: M.foo };
}
15 changes: 15 additions & 0 deletions harmony-tests/fail-resolve/export-cycle4.js
@@ -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 };
}
1 change: 1 addition & 0 deletions harmony-tests/fail-resolve/export-unbound-var.js
@@ -0,0 +1 @@
module M { export x }
2 changes: 2 additions & 0 deletions harmony-tests/fail-resolve/import-eval1.js
@@ -0,0 +1,2 @@
eval("module M { export var foo = 42 }");
import M.foo;
2 changes: 2 additions & 0 deletions harmony-tests/fail-resolve/import-eval2.js
@@ -0,0 +1,2 @@
eval("module M { export var foo = 42 }");
var x = M.foo;
5 changes: 5 additions & 0 deletions harmony-tests/fail-resolve/module-rebind-assignment1.js
@@ -0,0 +1,5 @@
module P { export module A { export var a = 12 } }

module B = P.A

B.a = 13;
1 change: 1 addition & 0 deletions harmony-tests/fail-resolve/unbound-read.js
@@ -0,0 +1 @@
var foo = someUnboundVariable;
1 change: 1 addition & 0 deletions harmony-tests/fail-resolve/unbound-write.js
@@ -0,0 +1 @@
someUnboundVariable = 12;
88 changes: 88 additions & 0 deletions harmony-tests/run.sh
@@ -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
5 changes: 5 additions & 0 deletions harmony-tests/succeed/eval-import1.js
@@ -0,0 +1,5 @@
module M {
export var foo = 42;
}

assertEq(eval("import M.foo; foo"), 42);
5 changes: 5 additions & 0 deletions harmony-tests/succeed/eval-import2.js
@@ -0,0 +1,5 @@
module M {
export var foo = "foo";
}

assertEq(eval("module M { export var bar = 'bar' } import M.bar; bar"), "bar");
9 changes: 9 additions & 0 deletions harmony-tests/succeed/eval-module1.js
@@ -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");
4 changes: 4 additions & 0 deletions harmony-tests/succeed/eval-module2.js
@@ -0,0 +1,4 @@
var M1 = eval("module M { } M");
var M2 = eval("module M { } M");

assertEq(M1 === M2, false);
5 changes: 5 additions & 0 deletions harmony-tests/succeed/eval-resolve1.js
@@ -0,0 +1,5 @@
var foo = 42;

var myfoo = eval("foo");

assertEq(foo, myfoo);
3 changes: 3 additions & 0 deletions harmony-tests/succeed/eval-resolve2.js
@@ -0,0 +1,3 @@
var foo = (function(x) { return eval("x") })("foo");

assertEq(foo, "foo");
12 changes: 12 additions & 0 deletions harmony-tests/succeed/export-bound-var.js
@@ -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);
5 changes: 5 additions & 0 deletions harmony-tests/succeed/export-var.js
@@ -0,0 +1,5 @@
module M {
export var foo = 42;
}

assertEq(M.foo, 42);
3 changes: 3 additions & 0 deletions harmony-tests/succeed/global-this.js
@@ -0,0 +1,3 @@
var global = this;

assertEq("global" in global, true);
8 changes: 8 additions & 0 deletions harmony-tests/succeed/incomplete-module1.js
@@ -0,0 +1,8 @@
var saved;

module M {
saved = M;
export var foo = 42;
}

assertEq("foo" in saved, true);
9 changes: 9 additions & 0 deletions harmony-tests/succeed/incomplete-module2.js
@@ -0,0 +1,9 @@
var saved;

module M {
export var foo = 42;
var tmp = M;
saved = tmp.foo;
}

assertEq(saved, 42);
1 change: 1 addition & 0 deletions harmony-tests/succeed/module-completion.js
@@ -0,0 +1 @@
assertEq(eval("module M { export var foo = 42 }").foo, 42);
8 changes: 8 additions & 0 deletions harmony-tests/succeed/module-rebind1.js
@@ -0,0 +1,8 @@
module P {
module A { export var a = 12 }
export A
}

module B = P.A

assertEq(B.a, 12);
10 changes: 10 additions & 0 deletions harmony-tests/succeed/module-rebind2.js
@@ -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);
9 changes: 9 additions & 0 deletions harmony-tests/succeed/module-rebind3.js
@@ -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);
8 changes: 8 additions & 0 deletions harmony-tests/succeed/module-this.js
@@ -0,0 +1,8 @@
var saved;

module M {
saved = this;
export var foo = 42;
}

assertEq("foo" in saved, true);
18 changes: 18 additions & 0 deletions harmony-tests/succeed/re-export1.js
@@ -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);
19 changes: 19 additions & 0 deletions harmony-tests/succeed/re-export2.js
@@ -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);
7 changes: 7 additions & 0 deletions harmony-tests/succeed/uninitialized-module1.js
@@ -0,0 +1,7 @@
var saved = M;

module M {
export var foo = 42;
}

assertEq(saved.foo, 42);
9 changes: 9 additions & 0 deletions harmony-tests/succeed/uninitialized-module2.js
@@ -0,0 +1,9 @@
var saved = M.N;

module M {
export module N {
export var foo = 42;
}
}

assertEq(saved.foo, 42);
14 changes: 14 additions & 0 deletions harmony-tests/succeed/uninitialized-module3.js
@@ -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);

0 comments on commit 901c5b3

Please sign in to comment.