aboutsummaryrefslogtreecommitdiff
path: root/tests/regex/testscript
blob: 1af604c3996f1caf1b5086fa8deb416ea90c510e (plain)
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
# file      : tests/regex/testscript
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

: match
:
{
  $*      abcbd b x >axcxd : all
  $* -ffo abcbd b x >axcbd : first-only
  $* -fnc abcbd b x >xx    : no-copy

  : ecma-escape
  :
  {
    $* xay a '$b'      >'x$by'  : none
    $* xay a '$'       >'x$y'   : none-term
    $* xay a '$$'      >'x$y'   : self
    $* xay a 'b$&c'    >'xbacy' : match
    $* xay a 'b$`c'    >'xbxcy' : match-precede
    $* xay a "b\\\$'c" >'xbycy' : match-follow

    : capture
    :
    $* abcdefghij '(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)' '$1$10' >aj
  }

  : perl-escape
  :
  {
    $* xay a '\b' >'xby' : none
    $* xay a '\'  >'xy'  : none-term
    $* xay a '\\' >'x\y' : self

    : capture
    :
    $* abcdefghij '(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)' '\1\10' >aa0

    : upper
    :
    {
      $* xay a       '\U'     >xy   : none
      $* xay a       '\Uvz'   >xVZy : repl
      $* xay a       '\Uv\Ez' >xVzy : end
      $* aa  a       'v\Uz'   >vZvZ : locality
      $* xay '(a)'   '\U\1'   >xAy  : capt
      $* x-y '(a?)-' '\U\1z'  >xZy  : capt-empty
      $* xay a       '\uvz'   >xVzy : once
    }

    : lower
    :
    $* xay a '\lVZ' >xvZy
  }
}