blob: f540e692ab35c09387d2c54ec89c06bc52b63356 [file] [log] [blame]
#!tools/lou_checkyaml
#
# Comparison of match and multi-pass opcodes
# ::::::::::::::::::::::::::::::::::::::::::
#
# Copyright © 2019 by Bert Frees
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
# ..............................................................................................
# use "display" also to define common part for all tests
# note that this is a hack and might break in the future
display: |
include tables/unicode-without-blank.dis
include tables/braille-patterns.cti
include tables/latinLetterDef8Dots.uti
include tables/loweredDigits6Dots.uti
space \s 0
letter ç 4-14
punctuation ! 2346
punctuation . 46
punctuation - 36
sign % 146
sign _ 145
# ..............................................................................................
# simple match replace
table: |
noback context "abc" @123
table : |
noback context ["abc"] @123
table: |
match - abc - 123
tests:
- - "abc"
- "⠇"
# lookbehind
table: |
always x 456
noback context _"x"["abc"] @123
table: |
always x 456
match x abc - 123
tests:
- - "xabc"
- "⠸⠇"
# without the _ it is not a true lookbehind
table: |
always x 456
noback context "x"["abc"] @123
tests:
- - "xabc"
- "⠸⠁⠃⠉"
# lookahead
table: |
always x 456
noback context ["abc"]"x" @123
table: |
always x 456
match - abc x 123
tests:
- - "abcx"
- "⠇⠸"
# zero-length match (insert)
# cursor advances at least one so that a zero-length match does not result in an endless loop
# with lookahead
table: |
always x 456
noback context []"xx" @123
tests:
- - "xxx"
- "⠇⠸⠇⠸⠸"
# with lookbehind
table: |
always x 456
noback context "x"[] @123
tests:
- - "xxx"
- "⠭⠇⠭⠇⠭⠇"
- xfail: got ⠇⠸⠇
table: |
always x 456
noback context "xx"[] @123
tests:
- - "xxx"
- "⠭⠭⠇⠭⠇"
- xfail: got ⠭⠭⠇⠸
# error: characters, dots, attributes, or class swap not found in test part
# table: |
# noback context _"x"[] @123
# tests:
# - - "xxx"
# - "⠇⠭⠇⠭⠇⠭"
# beginning of string
table: |
noback context `["abc"] @123
table: |
noback context `"abc" @123
table: |
match ^ abc - 123
table: |
match $ abc - 123
tests:
- - "xabc"
- "⠭⠁⠃⠉"
- - "abc"
- "⠇"
# end of string
table: |
noback context ["abc"]~ @123
table: |
noback context "abc"~ @123
table: |
match - abc $ 123
table: |
match - abc ^ 123
tests:
- - "abcx"
- "⠁⠃⠉⠭"
- - "abc"
- "⠇"
# wildcard
table: |
noback context ["abc"]$a"x" @123
table: |
match - abc .x 123
tests:
- - "abcdx"
- "⠇⠙⠭"
- - "abc!x"
- "⠇⠮⠭"
# character classes
table: |
noback context ["abc"]$U @123@1 # uppercase letter
noback context ["abc"]$u @123@2 # lowercase letter
noback context ["abc"]$l @123@3 # letter
noback context ["abc"]$p @123@4 # punctuation
noback context ["abc"]$d @123@5 # digit
noback context ["abc"]$s @123@6 # space
noback context ["abc"]$S @123@7 # sign
noback context ["def"]$sp @456 # space or punctuation
table: |
match - abc %u 123-1 # uppercase letter
match - abc %l 123-2 # lowercase letter
match - abc %a 123-3 # letter
match - abc %. 123-4 # punctuation
match - abc %# 123-5 # digit
match - abc %_ 123-6 # space
match - abc %$ 123-7 # sign
match - def %[_.] 456 # space or punctuation
tests:
- - "abcX"
- "⠇⠁⡭"
- - "abcx"
- "⠇⠂⠭"
- - "abcç"
- "⠇⠄⠈⠉"
- - "abc!"
- "⠇⠈⠮"
- - "abc1"
- "⠇⠐⠂"
- - "abc "
- "⠇⠠ "
- - "abc%"
- "⠇⡀⠩"
- - "def!"
- "⠸⠮"
- - "def "
- "⠸ "
- - "defx"
- "⠙⠑⠋⠭"
# character sets / custom character classes
table: |
class xy xy
noback context ["abc"]%xy @123
table: |
class xy xy
noback context ["abc"]$w @123
table: |
match - abc [xy] 123
table: |
match - abc x|y 123
table: |
match - abc (x|y) 123
table: |
attribute 0 xy
match - abc %0 123
table: |
class fo _
class foo _
class fooo _
class foooo _
class fooooo xy # fifth class
match - abc %0 123
tests:
- - "abcx"
- "⠇⠭"
- - "abcy"
- "⠇⠽"
- - "abcz"
- "⠁⠃⠉⠵"
# alternation
table: |
match - abc xy|z 123
table: |
noback context ["abc"]"xy" @123
noback context ["abc"]"z" @123
tests:
- - "abcx"
- "⠁⠃⠉⠭"
- - "abcxy"
- "⠇⠭⠽"
- - "abcz"
- "⠇⠵"
# repitition
# single character
table: |
match - abc x+y 123
table: |
class x x
noback context ["abc"]%x."y" @123
tests:
- - "abcy"
- "⠁⠃⠉⠽"
- - "abcxy"
- "⠇⠭⠽"
- - "abcxxy"
- "⠇⠭⠭⠽"
# character set/class
table: |
match - abc [xy]+z 123
table: |
match - abc (x|y)+z 123
table: |
class xy xy
noback context ["abc"]%xy."z" @123
tests:
- - "abcxz"
- "⠇⠭⠵"
- - "abcxyz"
- "⠇⠭⠽⠵"
- - "abcyyxz"
- "⠇⠽⠽⠭⠵"
# group of characters
table: |
match - abc (xy)+z 123
tests:
- - "abcxyz"
- "⠇⠭⠽⠵"
- - "abcxyxz"
- "⠁⠃⠉⠭⠽⠭⠵"
- - "abcxyxyz"
- "⠇⠭⠽⠭⠽⠵"
# zero or more
table: |
match - abc x*y 123
table: |
class x x
noback context ["abc"]"y" @123
noback context ["abc"]%x."y" @123
tests:
- - "abcy"
- "⠇⠽"
- - "abcxy"
- "⠇⠭⠽"
- - "abcxxy"
- "⠇⠭⠭⠽"
# optional
table: |
match - abc x?y 123
table: |
noback context ["abc"]"y" @123
noback context ["abc"]"xy" @123
tests:
- - "abcy"
- "⠇⠽"
- - "abcxy"
- "⠇⠭⠽"
- - "abcxxy"
- "⠁⠃⠉⠭⠭⠽"
# limiting repitition (not more than two)
table: |
class x x
noback context ["abc"]%x1-2"y" @123
tests:
- - "abcy"
- "⠁⠃⠉⠽"
- - "abcxy"
- "⠇⠭⠽"
- - "abcxxy"
- "⠇⠭⠭⠽"
- - "abcxxxy"
- "⠁⠃⠉⠭⠭⠭⠽"
# exact repitition
table: |
class x x
noback context ["abc"]%x2"y" @123
tests:
- - "abcxy"
- "⠁⠃⠉⠭⠽"
- - "abcxxy"
- "⠇⠭⠭⠽"
- - "abcxxxy"
- "⠁⠃⠉⠭⠭⠭⠽"
# three or more
table: |
class x x
noback context ["abc"]%x2%x."y" @123
tests:
- - "abcxxy"
- "⠁⠃⠉⠭⠭⠽"
- - "abcxxxy"
- "⠇⠭⠭⠭⠽"
- - "abcxxxxy"
- "⠇⠭⠭⠭⠭⠽"
# negation
table: |
match - abc !x 123
table: |
noback context ["abc"]!"x" @123
table: |
class x x
noback context ["abc"]!%x @123
tests:
- - "abcx"
- "⠁⠃⠉⠭"
- - "abcy"
- "⠇⠽"
- - "abc"
- "⠁⠃⠉"
# negated group
table: |
match - abc !(xy) 123
tests:
- - "abcx"
- "⠁⠃⠉⠭"
- - "abcxy"
- "⠁⠃⠉⠭⠽"
# replace with nothing
table: |
noback context "abc" ?
tests:
- - "xabcx"
- "⠭⠭"
# character classes in match
table: |
class xy xy
noback context $s @1
noback context $d. @3
noback context %xy @2
tests:
- - " "
- "⠁"
- - "y"
- "⠂"
- - "12345"
- "⠄"