main_testing3/re_test7.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 02 Nov 2023 23:34:53 +0000
changeset 475 59e005dcf163
parent 433 6af86ba1208f
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
153
4383809c176a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     2
def urbanmain() = {
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     3
  import M3._
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     4
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     5
  val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
153
4383809c176a updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
475
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     7
  assert(ders(("a" * 5).toList, EVIL_urban) == SEQs(List(STAR(CHAR('a')), STAR(STAR(CHAR('a'))), CHAR('b'))))
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     8
  assert(ders(List('b'), EVIL_urban) == ONE)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
     9
  assert(ders(List('b','b'), EVIL_urban) == ZERO)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    10
  assert(matcher(EVIL_urban, "a" * 5 ++ "b") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    11
  assert(matcher(EVIL_urban, "a" * 50 ++ "b") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    12
  assert(matcher(EVIL_urban, "a" * 50) == false)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    13
  assert(matcher(EVIL_urban, "b") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    14
  assert(matcher(EVIL_urban, "bb") == false)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    15
  assert(matcher("abc", "abc") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    16
  assert(matcher("abc", "ab") == false)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    17
  assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    18
  assert(matcher(ONE, "") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    19
  assert(matcher(ZERO, "") == false)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    20
  assert(matcher(ONE | CHAR('a'), "") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    21
  assert(matcher(ONE | CHAR('a'), "a") == true)
59e005dcf163 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 433
diff changeset
    22
}