Skip to content

Commit

Permalink
Merge pull request #55 from brianphillips/string-ranges
Browse files Browse the repository at this point in the history
make sure we support pre- and post-increment on string values
  • Loading branch information
prakashk committed Feb 15, 2013
2 parents e8bdae5 + 8c361c5 commit 6ea3536
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/main/scala/org/moe/interpreter/Interpreter.scala
Expand Up @@ -159,7 +159,9 @@ class Interpreter {
if (is_prefix) new_n else n
}
case s: MoeStringObject => {
env.set(varName, runtime.NativeObjects.getString(magicalStringIncrement(s.getNativeValue))).get
val new_s = runtime.NativeObjects.getString(magicalStringIncrement(s.getNativeValue))
env.set(varName, new_s)
if (is_prefix) new_s else s
}
}
}
Expand Down
Expand Up @@ -45,7 +45,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
IntLiteralNode(42)
),
IncrementNode(VariableAccessNode("$foo"), true),
IncrementNode(VariableAccessNode("$foo"), is_prefix = true),
VariableAccessNode("$foo")
)
)
Expand All @@ -60,7 +60,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
IntLiteralNode(42)
),
IncrementNode(VariableAccessNode("$foo"),true)
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand Down Expand Up @@ -105,7 +105,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
FloatLiteralNode(98.6)
),
IncrementNode(VariableAccessNode("$foo"), true),
IncrementNode(VariableAccessNode("$foo"), is_prefix = true),
VariableAccessNode("$foo")
)
)
Expand All @@ -120,7 +120,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
FloatLiteralNode(98.6)
),
IncrementNode(VariableAccessNode("$foo"), true)
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand Down Expand Up @@ -165,7 +165,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
IntLiteralNode(42)
),
DecrementNode(VariableAccessNode("$foo"), true),
DecrementNode(VariableAccessNode("$foo"), is_prefix = true),
VariableAccessNode("$foo")
)
)
Expand All @@ -180,7 +180,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
IntLiteralNode(42)
),
DecrementNode(VariableAccessNode("$foo"),true)
DecrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand Down Expand Up @@ -225,7 +225,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
FloatLiteralNode(98.6)
),
DecrementNode(VariableAccessNode("$foo"), true),
DecrementNode(VariableAccessNode("$foo"), is_prefix = true),
VariableAccessNode("$foo")
)
)
Expand All @@ -240,7 +240,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
FloatLiteralNode(98.6)
),
DecrementNode(VariableAccessNode("$foo"), true)
DecrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -254,7 +254,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("123")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -268,7 +268,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("99")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -282,7 +282,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("99")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -296,7 +296,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("a0")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -310,7 +310,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("Az")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -324,7 +324,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("zz")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand All @@ -338,7 +338,7 @@ class IncrementDecrementNodeTestSuite extends FunSuite with InterpreterTestUtils
"$foo",
StringLiteralNode("01")
),
IncrementNode(VariableAccessNode("$foo"))
IncrementNode(VariableAccessNode("$foo"), is_prefix = true)
)
)
val result = interpreter.eval(runtime, runtime.getRootEnv, ast)
Expand Down

0 comments on commit 6ea3536

Please sign in to comment.