[noop] push by tocman - Alex is forcing me to commit. on 2009-12-04 02:36 GMT

1 view
Skip to first unread message

no...@googlecode.com

unread,
Dec 3, 2009, 9:37:22 PM12/3/09
to noop-c...@googlegroups.com
Revision: 5c6e040fed
Author: Jeremie Lenfant-Engelmann <toc...@gmail.com>
Date: Thu Dec 3 18:36:36 2009
Log: Alex is forcing me to commit.
http://code.google.com/p/noop/source/detail?r=5c6e040fed

Added:
/core/src/main/scala/noop/model/ConditionalAndExpression.scala
/core/src/main/scala/noop/model/ConditionalOrExpression.scala
/interpreter/src/test/scala/noop/interpreter/ConditionalSpec.scala
Modified:
/buildfile
/core/src/main/antlr3/noop/grammar/antlr/Noop.g
/core/src/main/antlr3/noop/grammar/antlr/NoopAST.g
/core/src/main/scala/noop/model/CompositeVisitor.scala
/core/src/main/scala/noop/model/LoggingAstVisitor.scala
/core/src/main/scala/noop/model/OperatorExpression.scala
/core/src/main/scala/noop/model/Visitor.scala
/interpreter/src/main/noop/noop/Int.noop
/interpreter/src/main/scala/noop/interpreter/InterpreterModule.scala
/interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
/interpreter/src/main/scala/noop/types/NoopInteger.scala
/interpreter/src/test/scala/noop/interpreter/GuiceInterpreterFixture.scala
/interpreter/src/test/scala/noop/interpreter/InterpreterTestingModule.scala

=======================================
--- /dev/null
+++ /core/src/main/scala/noop/model/ConditionalAndExpression.scala Thu Dec
3 18:36:36 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package noop.model;
+
+/**
+ * @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
+ */
+class ConditionalAndExpression(val lhs: Expression, val rhs: Expression)
extends Expression {
+
+ def accept(visitor: Visitor) = {
+ lhs.accept(visitor);
+ visitor.visit(this);
+ rhs.accept(visitor);
+ visitor.visit(this);
+ }
+}
=======================================
--- /dev/null
+++ /core/src/main/scala/noop/model/ConditionalOrExpression.scala Thu Dec
3 18:36:36 2009
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package noop.model;
+
+/**
+ * @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
+ */
+class ConditionalOrExpression(val lhs: Expression, val rhs: Expression)
extends Expression {
+
+ def accept(visitor: Visitor) = {
+ lhs.accept(visitor);
+ visitor.visit(this);
+ rhs.accept(visitor);
+ visitor.visit(this);
+ }
+}
=======================================
--- /dev/null
+++ /interpreter/src/test/scala/noop/interpreter/ConditionalSpec.scala Thu
Dec 3 18:36:36 2009
@@ -0,0 +1,232 @@
+/**
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package noop.interpreter;
+
+import com.google.inject.Guice;
+
+import org.scalatest.matchers.ShouldMatchers;
+import org.scalatest.Spec;
+
+import model.{Block, IntLiteralExpression, OperatorExpression, Visitor};
+import types.{IntegerFactory, NoopBoolean, NoopTypesModule};
+
+/**
+ * @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
+ */
+class ConditionalSpec extends Spec with ShouldMatchers {
+
+ def createFixture = {
+ val injector = Guice.createInjector(new InterpreterModule(List()), new
NoopTypesModule());
+ val context = injector.getInstance(classOf[Context]);
+ val visitor = injector.getInstance(classOf[Visitor]);
+ (injector, context, visitor);
+ }
+
+ describe("conditional") {
+
+ it("should evaluate to true when equals is called and the values are
equal") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "==",
+ new IntLiteralExpression(1));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when equals is called and the values are
not equal") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "==",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+
+ it("should evaluate to true when doesNotEqual is called and the values
are not equal") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "!=",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when doesNotEqual is called and the
values are equal") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "!=",
+ new IntLiteralExpression(1));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+
+ it("should evaluate to true when greaterThan is called and the value
is greater than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(2), ">",
+ new IntLiteralExpression(1));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when greaterThan is called and the value
is less than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), ">",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+
+ it("should evaluate to true when lesserThan is called and the value is
less than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "<",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when lesserThan is called and the value
is greater than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(3), "<",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+
+ it("should evaluate to true when greaterOrEqualThan is called and the
value is greater or equal than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(3), ">=",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when greaterOrEqualThan is called and the
value is lesser than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), ">=",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+
+ it("should evaluate to true when lesserOrEqualThan is called and the
value is lesser or equal than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(1), "<=",
+ new IntLiteralExpression(2));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (true);
+ }
+
+ it("should evaluate to false when lesserOrEqualThan is called and the
value is greater than the other one") {
+ val (injector, context, visitor) = createFixture;
+ val integerFactory = injector.getInstance(classOf[IntegerFactory]);
+
+ context.addRootFrame(integerFactory.create(1));
+ val conditional = new OperatorExpression(new
IntLiteralExpression(2), "<=",
+ new IntLiteralExpression(1));
+
+ conditional.accept(visitor);
+ context.stack.top.lastEvaluated should have size(1);
+ val result = context.stack.top.lastEvaluated.top;
+
+ result.isInstanceOf[NoopBoolean] should be (true);
+ result.asInstanceOf[NoopBoolean].value should be (false);
+ }
+ }
+}
=======================================
--- /buildfile Sat Nov 21 21:07:02 2009
+++ /buildfile Thu Dec 3 18:36:36 2009
@@ -26,7 +26,7 @@

ANTLR = ["org.antlr:antlr:jar:3.1.1"]
ANTLR_RUNTIME = ["org.antlr:antlr-runtime:jar:3.1.1"]
-SLF4J = ["org.slf4j:slf4j-api:jar:1.5.6", "org.slf4j:slf4j-nop:jar:1.5.6"]
+SLF4J =
["org.slf4j:slf4j-api:jar:1.5.6", "org.slf4j:slf4j-simple:jar:1.5.6"]
GUICE = ["aopalliance:aopalliance:jar:1.0",
"com.google.inject:guice:jar:2.0", "com.google.inject.extensions:guice-assisted-inject:jar:2.0"
]
# Force Buildr Antlr integration to use the version we specify
=======================================
--- /core/src/main/antlr3/noop/grammar/antlr/Noop.g Wed Nov 25 15:56:45 2009
+++ /core/src/main/antlr3/noop/grammar/antlr/Noop.g Thu Dec 3 18:36:36 2009
@@ -194,7 +194,7 @@
;

statement
- : identifierDeclaration ';'!
+ : identifierDeclaration ';'!
| whileLoop
| forLoop
| 'return'^ expression ';'!
=======================================
--- /core/src/main/antlr3/noop/grammar/antlr/NoopAST.g Wed Nov 25 15:40:07
2009
+++ /core/src/main/antlr3/noop/grammar/antlr/NoopAST.g Thu Dec 3 18:36:36
2009
@@ -317,6 +317,8 @@
{ $exp = $o.exp; }
| ass=assignment
{ $exp = $ass.exp; }
+ | c=conditionalExpression
+ { $exp = $c.exp; }
| right=(VariableIdentifier|TypeIdentifier) a=arguments?
{ Expression left = new IdentifierExpression("this");
if ($a.args != null) {
@@ -326,9 +328,20 @@
}
}
;
+
+conditionalExpression returns [Expression exp]
+ : ^(cond=('||' | '&&') left=expression right=expression)
+ {
+ if ($cond.text.equals("||")) {
+ $exp = new ConditionalOrExpression($left.exp, $right.exp);
+ } else if ($cond.text.equals("&&")) {
+ $exp = new ConditionalAndExpression($left.exp, $right.exp);
+ }
+ }
+ ;

operatorExpression returns [Expression exp]
- : ^(op=('+'|'-'|'*'|'/'|'%') left=expression right=expression)
+ : ^(op=('+' | '-' | '*' | '/' | '%' | '==' | '!=' | '>' | '<' | '>='
| '<=') left=expression right=expression)
{ $exp = new OperatorExpression($left.exp, $op.text, $right.exp); }
;

=======================================
--- /core/src/main/scala/noop/model/CompositeVisitor.scala Sat Nov 7
12:07:39 2009
+++ /core/src/main/scala/noop/model/CompositeVisitor.scala Thu Dec 3
18:36:36 2009
@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package noop.model
+package noop.model;

/**
* @author alex...@google.com (Alex Eagle)
* TODO(alex): looks like we could have a single visit(Expression) method
*/
-
class CompositeVisitor(visitors: Seq[Visitor]) extends Visitor {
+
def visit(assignmentExpression: AssignmentExpression) {
for (v <- visitors) {
v.visit(assignmentExpression);
@@ -128,4 +128,16 @@
v.visit(bindingDeclaration);
}
}
-}
+
+ def visit(conditionalAndExpression: ConditionalAndExpression) = {
+ for (v <- visitors) {
+ v.visit(conditionalAndExpression);
+ }
+ }
+
+ def visit(conditionalOrExpression: ConditionalOrExpression) = {
+ for (v <- visitors) {
+ v.visit(conditionalOrExpression);
+ }
+ }
+}
=======================================
--- /core/src/main/scala/noop/model/LoggingAstVisitor.scala Sat Nov 7
12:07:39 2009
+++ /core/src/main/scala/noop/model/LoggingAstVisitor.scala Thu Dec 3
18:36:36 2009
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package noop.model
+package noop.model;

import org.slf4j.LoggerFactory;

@@ -97,4 +97,12 @@
def visit(bindingDeclaration: BindingDeclaration) = {
logger.info("binding {} to {}", bindingDeclaration.noopType,
bindingDeclaration.binding);
}
-}
+
+ def visit(conditionalAndExpression: ConditionalAndExpression) = {
+ logger.info("and conditional expression");
+ }
+
+ def visit(conditionalOrExpression: ConditionalOrExpression) = {
+ logger.info("or conditional expression");
+ }
+}
=======================================
--- /core/src/main/scala/noop/model/OperatorExpression.scala Thu Oct 8
10:25:57 2009
+++ /core/src/main/scala/noop/model/OperatorExpression.scala Thu Dec 3
18:36:36 2009
@@ -29,6 +29,12 @@
case "*" => "multiply";
case "/" => "divide";
case "%" => "modulo";
+ case "==" => "equals";
+ case "!=" => "doesNotEqual";
+ case ">" => "greaterThan";
+ case "<" => "lesserThan";
+ case ">=" => "greaterOrEqualThan";
+ case "<=" => "lesserOrEqualThan";
}

new MethodInvocationExpression(left, methodName,
List(right)).accept(visitor);
=======================================
--- /core/src/main/scala/noop/model/Visitor.scala Sat Nov 7 12:07:39 2009
+++ /core/src/main/scala/noop/model/Visitor.scala Thu Dec 3 18:36:36 2009
@@ -54,5 +54,9 @@

def visit(whileLoop: WhileLoop);

- def visit(bindingDeclaration: BindingDeclaration);
-}
+ def visit(bindingDeclaration: BindingDeclaration);
+
+ def visit(conditionalAndExpression: ConditionalAndExpression);
+
+ def visit(conditionalOrExpression: ConditionalOrExpression);
+}
=======================================
--- /interpreter/src/main/noop/noop/Int.noop Fri Nov 13 11:55:04 2009
+++ /interpreter/src/main/noop/noop/Int.noop Thu Dec 3 18:36:36 2009
@@ -20,5 +20,11 @@
native Int multiply(Int other) {}
native Int divide(Int other) {}
native Int modulo(Int other) {}
+ native Boolean equals(Object other) {}
+ native Boolean doesNotEqual(Object other) {}
+ native Boolean greaterThan(Object other) {}
+ native Boolean lesserThan(Object other) {}
+ native Boolean greaterOrEqualThan(Object other) {}
+ native Boolean lesserOrEqualThan(Object other) {}
native String toString() {}
}
=======================================
--- /interpreter/src/main/scala/noop/interpreter/InterpreterModule.scala
Fri Nov 13 11:55:04 2009
+++ /interpreter/src/main/scala/noop/interpreter/InterpreterModule.scala
Thu Dec 3 18:36:36 2009
@@ -26,7 +26,6 @@
/**
* @author alex...@google.com (Alex Eagle)
*/
-
class InterpreterModule(srcRoots: List[String]) extends AbstractModule {
override def configure() = {
bind(classOf[ClassSearch]).to(classOf[SourceFileClassLoader]);
=======================================
--- /interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala
Fri Nov 13 16:27:54 2009
+++ /interpreter/src/main/scala/noop/interpreter/InterpreterVisitor.scala
Thu Dec 3 18:36:36 2009
@@ -15,25 +15,29 @@
*/
package noop.interpreter;

-import com.google.inject.Inject
-import inject.Injector
-import model._
-import org.slf4j.LoggerFactory
-import scala.collection.mutable.ArrayBuffer
-import types._
-
+import com.google.inject.Inject;
+import inject.Injector;
+import org.slf4j.LoggerFactory;
+
+import scala.collection.mutable.ArrayBuffer;

import interpreter.testing.TestFailedException;
-
-
+import model.{AssignmentExpression, BindingDeclaration, Block,
BooleanLiteralExpression,
+ ConditionalAndExpression, ConditionalOrExpression,
DereferenceExpression,
+ EvaluatedExpression, IdentifierDeclarationExpression,
IdentifierExpression,
+ IntLiteralExpression, Method, MethodInvocationExpression, Modifier,
+ OperatorExpression, ReturnExpression, ShouldExpression,
StringLiteralExpression,
+ Visitor, WhileLoop};
+import types._;

/**
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
-class InterpreterVisitor @Inject() (val context: Context, injector:
Injector, booleanFactory: BooleanFactory,
- stringFactory: StringFactory,
integerFactory: IntegerFactory)
+class InterpreterVisitor @Inject() (val context: Context, injector:
Injector,
+ booleanFactory: BooleanFactory, stringFactory: StringFactory,
integerFactory: IntegerFactory)
extends Visitor {
+
val logger = LoggerFactory.getLogger(this.getClass());

def visit(assignmentExpression: AssignmentExpression) = {
@@ -177,4 +181,10 @@
// fixture.addBinding(bindingDeclaration.noopType, boundValue);
context.stack.top.lastEvaluated.clear();
}
-}
+
+ def visit(conditionalAndExpression: ConditionalAndExpression) = {
+ }
+
+ def visit(conditionalOrExpression: ConditionalOrExpression) = {
+ }
+}
=======================================
---
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
Tue Nov 17 18:47:39 2009
+++
/interpreter/src/main/scala/noop/interpreter/SourceFileClassLoader.scala
Thu Dec 3 18:36:36 2009
@@ -15,8 +15,6 @@
*/
package noop.interpreter;

-
-
import collection.mutable.Map
import java.io.{InputStream, FileInputStream, File}
import model.{Parameter, ClassDefinition};
@@ -24,7 +22,6 @@

import grammar.{ParseException, Parser};

-
/**
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
=======================================
--- /interpreter/src/main/scala/noop/types/NoopInteger.scala Thu Nov 12
22:16:59 2009
+++ /interpreter/src/main/scala/noop/types/NoopInteger.scala Thu Dec 3
18:36:36 2009
@@ -22,14 +22,17 @@
import com.google.inject.assistedinject.Assisted;
import com.google.inject.Inject;

+import scala.collection.immutable;
+
+import model.ClassDefinition;
+
/**
* @author alex...@google.com (Alex Eagle)
* @author toc...@gmail.com (Jeremie Lenfant-Engelmann)
*/
class NoopInteger @Inject() (@Named("Int") classDef: ClassDefinition,
- integerFactory: IntegerFactory,
stringFactory: StringFactory,
- @Assisted val value: Int)
- extends NoopObject(classDef) {
+ integerFactory: IntegerFactory, stringFactory: StringFactory,
booleanFactory: BooleanFactory,
+ @Assisted val value: Int) extends NoopObject(classDef) {

def other(args: Seq[NoopObject]): Int = {
args(0).asInstanceOf[NoopInteger].value;
@@ -41,6 +44,12 @@
"multiply" -> ((args: Seq[NoopObject]) => integerFactory.create(value
* other(args))),
"divide" -> ((args: Seq[NoopObject]) => integerFactory.create(value /
other(args))),
"modulo" -> ((args: Seq[NoopObject]) => integerFactory.create(value %
other(args))),
+ "equals" -> ((args: Seq[NoopObject]) => booleanFactory.create(value ==
other(args))),
+ "doesNotEqual" -> ((args: Seq[NoopObject]) =>
booleanFactory.create(value != other(args))),
+ "greaterThan" -> ((args: Seq[NoopObject]) =>
booleanFactory.create(value > other(args))),
+ "lesserThan" -> ((args: Seq[NoopObject]) =>
booleanFactory.create(value < other(args))),
+ "greaterOrEqualThan" -> ((args: Seq[NoopObject]) =>
booleanFactory.create(value >= other(args))),
+ "lesserOrEqualThan" -> ((args: Seq[NoopObject]) =>
booleanFactory.create(value <= other(args))),
"toString" -> ((args: Seq[NoopObject]) =>
stringFactory.create(value.toString))
);

=======================================
---
/interpreter/src/test/scala/noop/interpreter/GuiceInterpreterFixture.scala
Fri Nov 13 11:55:04 2009
+++
/interpreter/src/test/scala/noop/interpreter/GuiceInterpreterFixture.scala
Thu Dec 3 18:36:36 2009
@@ -19,10 +19,10 @@
import java.io.File;
import com.google.inject.{Injector, Guice};
import types.{StringFactory, NoopTypesModule};
+
/**
* @author alex...@google.com (Alex Eagle)
*/
-
trait GuiceInterpreterFixture {
def fixture: Injector = {
val injector = Guice.createInjector(
=======================================
---
/interpreter/src/test/scala/noop/interpreter/InterpreterTestingModule.scala
Fri Nov 13 16:27:54 2009
+++
/interpreter/src/test/scala/noop/interpreter/InterpreterTestingModule.scala
Thu Dec 3 18:36:36 2009
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package noop.interpreter
+package noop.interpreter;

import model.{Method, Modifier, ClassDefinition};
import com.google.inject.{Provides, AbstractModule, Singleton};
+
/**
* This module sets up a classloader which doesn't rely on reading
real .noop files to get the
* standard library classes.
Reply all
Reply to author
Forward
0 new messages