summaryrefslogtreecommitdiff
path: root/examples/scala-js/test-suite/src/test/scala/scala/scalajs/testsuite/compiler/UnitTest.scala
blob: 8e2be6458d5d005bc4dbf34535b3a762181899de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*                     __                                               *\
**     ________ ___   / /  ___      __ ____  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 UnitTest extends JasmineTest {

  describe("Unit primitive") {

    it("should have toString()") {
      expect(().toString()).toEqual("undefined")
      expect(((): Any).toString()).toEqual("undefined")
    }

    it("should have hashCode()") {
      expect(().hashCode()).toEqual(0)
      expect(((): Any).hashCode()).toEqual(0)
      expect(().##).toEqual(0)
    }

    it("should equal itself") {
      expect(().equals(())).toBeTruthy
      expect(((): Any).equals((): Any)).toBeTruthy
    }

    it("should not equal other values") {
      def testAgainst(v: Any): Unit = {
        expect(().equals(v)).toBeFalsy
        expect(((): Any).equals(v)).toBeFalsy
      }

      testAgainst(0)
      testAgainst(1)
      testAgainst(null)
      testAgainst(false)
      testAgainst("")
    }

  }
}