diff options
Diffstat (limited to 'scalajslib/test/resources')
6 files changed, 81 insertions, 1 deletions
diff --git a/scalajslib/test/resources/hello-js-world/src/ArgsParser.scala b/scalajslib/test/resources/hello-js-world/src/ArgsParser.scala new file mode 100644 index 00000000..cf13d452 --- /dev/null +++ b/scalajslib/test/resources/hello-js-world/src/ArgsParser.scala @@ -0,0 +1,3 @@ +object ArgsParser { + def parse(s:String): Seq[String] = s.split(":").toSeq +} diff --git a/scalajslib/test/resources/hello-js-world/src/Main.scala b/scalajslib/test/resources/hello-js-world/src/Main.scala index 60cef56d..636d9ea1 100644 --- a/scalajslib/test/resources/hello-js-world/src/Main.scala +++ b/scalajslib/test/resources/hello-js-world/src/Main.scala @@ -1,3 +1,6 @@ object Main extends App { - println("Hello " + sys.props("java.vm.name")) + + println("Hello " + vmName) + + def vmName = sys.props("java.vm.name") } diff --git a/scalajslib/test/resources/hello-js-world/test/src/scalatest/ArgsParserSpec.scala b/scalajslib/test/resources/hello-js-world/test/src/scalatest/ArgsParserSpec.scala new file mode 100644 index 00000000..807decb9 --- /dev/null +++ b/scalajslib/test/resources/hello-js-world/test/src/scalatest/ArgsParserSpec.scala @@ -0,0 +1,18 @@ +import org.scalatest._ + +class ArgsParserSpec extends FlatSpec with Matchers { + + behavior of "ArgsParser" + + "parse" should "one" in { + val result = ArgsParser.parse("hello:world") + result should have length 2 + result should contain only ("hello", "world") + } + + it should "two" in { + val result = ArgsParser.parse("hello:world") + result should have length 80 + } + +} diff --git a/scalajslib/test/resources/hello-js-world/test/src/scalatest/MainSpec.scala b/scalajslib/test/resources/hello-js-world/test/src/scalatest/MainSpec.scala new file mode 100644 index 00000000..0c1eb76f --- /dev/null +++ b/scalajslib/test/resources/hello-js-world/test/src/scalatest/MainSpec.scala @@ -0,0 +1,15 @@ +import org.scalatest._ + +class MainSpec extends FlatSpec with Matchers { + + behavior of "Main" + + "vmName" should "contain js" in { + Main.vmName should include ("js") + } + + it should "contain Scala" in { + Main.vmName should include ("Scala") + } + +} diff --git a/scalajslib/test/resources/hello-js-world/test/src/utest/ArgsParserTests.scala b/scalajslib/test/resources/hello-js-world/test/src/utest/ArgsParserTests.scala new file mode 100644 index 00000000..d0baa965 --- /dev/null +++ b/scalajslib/test/resources/hello-js-world/test/src/utest/ArgsParserTests.scala @@ -0,0 +1,21 @@ +import utest._ + +object ArgsParserTests extends TestSuite { + + def tests: Tests = Tests { + 'one - { + val result = ArgsParser.parse("hello:world") + assert( + result.length == 2, + result == Seq("hello", "world") + ) + } + 'two - { // we fail this test to check testing in scala.js + val result = ArgsParser.parse("hello:world") + assert( + result.length == 80 + ) + } + } + +} diff --git a/scalajslib/test/resources/hello-js-world/test/src/utest/MainTests.scala b/scalajslib/test/resources/hello-js-world/test/src/utest/MainTests.scala new file mode 100644 index 00000000..937d96f8 --- /dev/null +++ b/scalajslib/test/resources/hello-js-world/test/src/utest/MainTests.scala @@ -0,0 +1,20 @@ +import utest._ + +object MainTests extends TestSuite { + + def tests: Tests = Tests { + 'vmName - { + 'containJs - { + assert( + Main.vmName.contains("js") + ) + } + 'containScala - { + assert( + Main.vmName.contains("Scala") + ) + } + } + } + +} |