Skip to content

Commit

Permalink
Testing hashref in an arrayref
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Feb 13, 2013
1 parent 51326ab commit 211e351
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/test/scala/org/moe/parser/ArrayLiteralTestSuite.scala
Expand Up @@ -28,7 +28,7 @@ class ArrayLiteralTestSuite extends FunSuite with BeforeAndAfter with ParserTest
assert(elems(3).asInstanceOf[MoeBooleanObject].getNativeValue === true);
}

test("... basic test with nested arrayrefs") {
test("... basic test with a nested arrayref") {
val result = interpretCode("""[42, ['jason', "may"], true]""")
val elems = result.asInstanceOf[MoeArrayObject].getNativeValue

Expand All @@ -41,6 +41,18 @@ class ArrayLiteralTestSuite extends FunSuite with BeforeAndAfter with ParserTest
assert(elems(2).asInstanceOf[MoeBooleanObject].getNativeValue === true);
}

test("... basic test with a nested hashref") {
val result = interpretCode("""[42, {'jason' => "may"}, false]""")
val elems = result.asInstanceOf[MoeArrayObject].getNativeValue

assert(elems(0).asInstanceOf[MoeIntObject].getNativeValue === 42);

val nested_hash = elems(1).asInstanceOf[MoeHashObject].getNativeValue
val key = nested_hash("jason")
assert(key.asInstanceOf[MoeStringObject].getNativeValue === "may")
assert(elems(2).asInstanceOf[MoeBooleanObject].getNativeValue === false);
}

test("... basic test with arrayref containing a right-trailing list") {
val result = interpretCode("[42, true, ]")
val elems = result.asInstanceOf[MoeArrayObject].getNativeValue
Expand Down

0 comments on commit 211e351

Please sign in to comment.