aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/scala/org/perl8/test/tests/testmore/basic.scala
blob: d40a218632fbeb53037aa3877df6b947b999c5f2 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package org.perl8.test.tests.testmore

import org.scalatest.FunSuite

import org.perl8.test.TestMore

import java.io.ByteArrayOutputStream

object OutputContainer {
  val output = new ByteArrayOutputStream
}

class MyBasicTest extends TestMore(OutputContainer.output) {
  diag("ok")
  ok(1 == 1, "it works!")
  ok(0 == 1, "it doesn't work!")
  ok(1 == 1)
  ok(0 == 1)

  diag("is")
  is(1, 1, "it works!")
  is(1, 0, "it doesn't work!")
  is(1, 1)
  is(1, 0)

  diag("isnt")
  isnt(1, 0, "it works!")
  isnt(1, 1, "it doesn't work!")
  isnt(1, 0)
  isnt(1, 1)

  diag("like")
  like("foo", """foo""".r, "it works!")
  like("foo", """bar""".r, "it doesn't work!")
  like("foo", """foo""".r)
  like("foo", """bar""".r)

  subtest("unlikes") {
    diag("unlike")
    unlike("foo", """bar""".r, "it works!")
    unlike("foo", """foo""".r, "it doesn't work!")
    unlike("foo", """bar""".r)
    unlike("foo", """foo""".r)
  }

  diag("pass")
  pass("it works!")
  pass()

  skip(2, "don't do this yet") {
    pass("skipped")
    pass()
  }

  todo("not working yet") {
    diag("fail")
    fail("it doesn't work")
    fail()
  }
}

class Basic extends FunSuite {
  test ("basic") {
    assert((new MyBasicTest).run == 9)

    val expected =
      "# ok\n" +
      "ok 1 - it works!\n" +
      "not ok 2 - it doesn't work!\n" +
      "#   Failed test 'it doesn't work!'\n" +
      "#   at basic.scala line 16.\n" +
      "ok 3\n" +
      "not ok 4\n" +
      "#   Failed test at basic.scala line 18.\n" +
      "# is\n" +
      "ok 5 - it works!\n" +
      "not ok 6 - it doesn't work!\n" +
      "#   Failed test 'it doesn't work!'\n" +
      "#   at basic.scala line 22.\n" +
      "#          got: '1'\n" +
      "#     expected: '0'\n" +
      "ok 7\n" +
      "not ok 8\n" +
      "#   Failed test at basic.scala line 24.\n" +
      "#          got: '1'\n" +
      "#     expected: '0'\n" +
      "# isnt\n" +
      "ok 9 - it works!\n" +
      "not ok 10 - it doesn't work!\n" +
      "#   Failed test 'it doesn't work!'\n" +
      "#   at basic.scala line 28.\n" +
      "#          got: '1'\n" +
      "#     expected: anything else\n" +
      "ok 11\n" +
      "not ok 12\n" +
      "#   Failed test at basic.scala line 30.\n" +
      "#          got: '1'\n" +
      "#     expected: anything else\n" +
      "# like\n" +
      "ok 13 - it works!\n" +
      "not ok 14 - it doesn't work!\n" +
      "#   Failed test 'it doesn't work!'\n" +
      "#   at basic.scala line 34.\n" +
      "#                   'foo'\n" +
      "#     doesn't match 'bar'\n" +
      "ok 15\n" +
      "not ok 16\n" +
      "#   Failed test at basic.scala line 36.\n" +
      "#                   'foo'\n" +
      "#     doesn't match 'bar'\n" +
      "    # unlike\n" +
      "    ok 1 - it works!\n" +
      "    not ok 2 - it doesn't work!\n" +
      "    #   Failed test 'it doesn't work!'\n" +
      "    #   at basic.scala line 41.\n" +
      "    #                   'foo'\n" +
      "    #           matches 'foo'\n" +
      "    ok 3\n" +
      "    not ok 4\n" +
      "    #   Failed test at basic.scala line 43.\n" +
      "    #                   'foo'\n" +
      "    #           matches 'foo'\n" +
      "    1..4\n" +
      "    # Looks like you failed 2 tests of 4.\n" +
      "not ok 17 - unlikes\n" +
      "#   Failed test 'unlikes'\n" +
      "#   at basic.scala line 38.\n" +
      "# pass\n" +
      "ok 18 - it works!\n" +
      "ok 19\n" +
      "ok 20 # skip don't do this yet\n" +
      "ok 21 # skip don't do this yet\n" +
      "# fail\n" +
      "not ok 22 - it doesn't work # TODO not working yet\n" +
      "#   Failed (TODO) test 'it doesn't work'\n" +
      "#   at basic.scala line 57.\n" +
      "not ok 23 # TODO not working yet\n" +
      "#   Failed (TODO) test at basic.scala line 58.\n" +
      "1..23\n" +
      "# Looks like you failed 9 tests of 23.\n"

    assert(OutputContainer.output.toString === expected)
  }
}