diff options
Diffstat (limited to 'scalanativelib/test/resources')
6 files changed, 97 insertions, 0 deletions
diff --git a/scalanativelib/test/resources/hello-native-world/src/hello/ArgsParser.scala b/scalanativelib/test/resources/hello-native-world/src/hello/ArgsParser.scala new file mode 100644 index 00000000..8ad93598 --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/src/hello/ArgsParser.scala @@ -0,0 +1,5 @@ +package hello + +object ArgsParser { + def parse(s:String): Seq[String] = s.split(":").toSeq +} diff --git a/scalanativelib/test/resources/hello-native-world/src/hello/Main.scala b/scalanativelib/test/resources/hello-native-world/src/hello/Main.scala new file mode 100644 index 00000000..5e04dbb3 --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/src/hello/Main.scala @@ -0,0 +1,6 @@ +package hello + +object Main extends App { + println("Hello " + vmName) + def vmName = sys.props("java.vm.name") +} diff --git a/scalanativelib/test/resources/hello-native-world/test/src/scalatest/ArgsParserSpec.scala b/scalanativelib/test/resources/hello-native-world/test/src/scalatest/ArgsParserSpec.scala new file mode 100644 index 00000000..dd160989 --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/test/src/scalatest/ArgsParserSpec.scala @@ -0,0 +1,21 @@ +package hellotest + +import hello._ +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/scalanativelib/test/resources/hello-native-world/test/src/scalatest/MainSpec.scala b/scalanativelib/test/resources/hello-native-world/test/src/scalatest/MainSpec.scala new file mode 100644 index 00000000..582c3692 --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/test/src/scalatest/MainSpec.scala @@ -0,0 +1,18 @@ +package hellotest + +import hello._ +import org.scalatest._ + +class MainSpec extends FlatSpec with Matchers { + + behavior of "Main" + + "vmName" should "contain Native" in { + Main.vmName should include ("Native") + } + + it should "contain Scala" in { + Main.vmName should include ("Scala") + } + +} diff --git a/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/ArgsParserTests.scala b/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/ArgsParserTests.scala new file mode 100644 index 00000000..7929f947 --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/ArgsParserTests.scala @@ -0,0 +1,24 @@ +package hellotest + +import hello._ +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/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/MainTests.scala b/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/MainTests.scala new file mode 100644 index 00000000..3a89f90c --- /dev/null +++ b/scalanativelib/test/resources/hello-native-world/test/src/utest/tests/MainTests.scala @@ -0,0 +1,23 @@ +package hellotest + +import hello._ +import utest._ + +object MainTests extends TestSuite { + + def tests: Tests = Tests { + 'vmName - { + 'containNative - { + assert( + Main.vmName.contains("Native") + ) + } + 'containScala - { + assert( + Main.vmName.contains("Scala") + ) + } + } + } + +} |