main_marking3/re_test4.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 29 Jan 2021 00:56:19 +0000
changeset 390 175a950470a9
child 424 daf561a83ba6
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
390
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
import CW8c._
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
val EVIL_urban = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
assert(ders(("a" * 5).toList, EVIL_urban) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')))
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
assert(ders(List('b'), EVIL_urban) == ONE)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
assert(ders(List('b','b'), EVIL_urban) == ZERO)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
assert(matcher(EVIL_urban, "a" * 5 ++ "b") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
assert(matcher(EVIL_urban, "a" * 50 ++ "b") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
assert(matcher(EVIL_urban, "a" * 50) == false)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
assert(matcher(EVIL_urban, "b") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
assert(matcher(EVIL_urban, "bb") == false)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
assert(matcher("abc", "abc") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
assert(matcher("abc", "ab") == false)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
assert(matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
assert(matcher(ONE, "") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
assert(matcher(ZERO, "") == false)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
assert(matcher(ONE | CHAR('a'), "") == true)
175a950470a9 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
assert(matcher(ONE | CHAR('a'), "a") == true)