diff options
author | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
---|---|---|
committer | Haoyi Li <haoyi@haoyi-mbp.corp.dropbox.com> | 2014-11-26 00:45:31 -0800 |
commit | 2c4b142503bd2d871e6818b5cab8c38627d9e4a0 (patch) | |
tree | 6ba33d2980a1a7a1286100202a695c6631bd240e /test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala | |
download | hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.gz hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.tar.bz2 hands-on-scala-js-2c4b142503bd2d871e6818b5cab8c38627d9e4a0.zip |
Squashed 'examples/scala-js/' content from commit 47311ba
git-subtree-dir: examples/scala-js
git-subtree-split: 47311ba693f949f204f27ea9475bb63425fbd4f3
Diffstat (limited to 'test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala')
-rw-r--r-- | test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala b/test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala new file mode 100644 index 0000000..9f48993 --- /dev/null +++ b/test-suite/src/test/scala/scala/scalajs/testsuite/compiler/ByteTest.scala @@ -0,0 +1,40 @@ +/* __ *\ +** ________ ___ / / ___ __ ____ Scala.js Test Suite ** +** / __/ __// _ | / / / _ | __ / // __/ (c) 2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ ** +** /____/\___/_/ |_/____/_/ | |__/ /____/ ** +** |/____/ ** +\* */ +package scala.scalajs.testsuite.compiler + +import org.scalajs.jasminetest.JasmineTest +import scala.scalajs.js + +object ByteTest extends JasmineTest { + + describe("Byte primitives") { + + it("should always be in their range") { + def test(x: Int, y: Byte): Unit = + expect(x.toByte).toEqual(y) + + test(0, 0) + test(127, 127) + test(128, -128) + test(-128, -128) + test(-500, 12) + test(-90000, 112) + test(123456789, 21) + test(-40000, -64) + test(65536, 0) + test(32768, 0) + + def testC(x: Char, y: Byte): Unit = + expect(x.toByte).toEqual(y) + + testC(-1.toChar, -1) + testC(200.toChar, -56) + } + + } +} |