Browse files

implementing void unary operator

  • Loading branch information...
1 parent 8f9ac50 commit 5ab9a5e6c365888218a62952a115199e97441ed9 @qmx qmx committed May 4, 2012
Showing with 15 additions and 2 deletions.
  1. +10 −2 src/main/java/org/dynjs/parser/Executor.java
  2. +5 −0 src/test/java/org/dynjs/runtime/DynJSTest.java
View
12 src/main/java/org/dynjs/parser/Executor.java
@@ -123,8 +123,16 @@ public Statement defineDeleteOp(Statement expression) {
throw new DynJSException("not implemented yet");
}
- public Statement defineVoidOp(Statement expression) {
- throw new DynJSException("not implemented yet");
+ public Statement defineVoidOp(final Statement expression) {
+ return new Statement() {
+ @Override
+ public CodeBlock getCodeBlock() {
+ return new CodeBlock(){{
+ append(expression.getCodeBlock());
+ append(new UndefinedValueStatement().getCodeBlock());
+ }};
+ }
+ };
}
public Statement defineTypeOfOp(final Statement expression) {
View
5 src/test/java/org/dynjs/runtime/DynJSTest.java
@@ -264,6 +264,11 @@ public void testTypeOf() {
check("function x(){}; var result = typeof x === 'function';");
}
+ @Test
+ public void testVoid() {
+ check("var result = undefined === undefined;");
+ }
+
private void check(String scriptlet) {
check(scriptlet, true);
}

0 comments on commit 5ab9a5e

Please sign in to comment.