From c59499df79e8cc29a0f8f254776ec93e83132ce4 Mon Sep 17 00:00:00 2001 From: rexim Date: Sun, 30 Oct 2016 22:56:32 +0600 Subject: [PATCH] Add ohce sample and add it to funtests (#281) --- docs/samples/04-ohce.mgn | 3 +++ .../scala/me/rexim/morganey/funtests/SamplesFuntest.scala | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 docs/samples/04-ohce.mgn diff --git a/docs/samples/04-ohce.mgn b/docs/samples/04-ohce.mgn new file mode 100644 index 0000000..b24889e --- /dev/null +++ b/docs/samples/04-ohce.mgn @@ -0,0 +1,3 @@ +load std.prelude + +main := reverse input diff --git a/funtests/src/test/scala/me/rexim/morganey/funtests/SamplesFuntest.scala b/funtests/src/test/scala/me/rexim/morganey/funtests/SamplesFuntest.scala index f5f26f7..6722f6c 100644 --- a/funtests/src/test/scala/me/rexim/morganey/funtests/SamplesFuntest.scala +++ b/funtests/src/test/scala/me/rexim/morganey/funtests/SamplesFuntest.scala @@ -24,4 +24,12 @@ class SamplesFuntest extends FlatSpec with Matchers with MorganeyProcess { actualOutput should be (expectedOutput) } + + "ohcE sample" should "print the user's input backwards" in { + val input = new ByteArrayInputStream("Hello".getBytes("UTF-8")) + val expectedOutput = s"""string: \"olleH\"${System.lineSeparator()}""" + val actualOutput = morganey("./docs/samples/04-ohce.mgn") #< input !! + + actualOutput should be (expectedOutput) + } }