1 # This set of tests exercises the serialization/deserialization and code copy 2 # functions in the library. It does not use UTF or JIT. 3 4 #forbid_utf 5 6 # Compile several patterns, push them onto the stack, and then write them 7 # all to a file. 8 9 #pattern push 10 11 /(?<NAME>(?&NAME_PAT))\s+(?<ADDR>(?&ADDRESS_PAT)) 12 (?(DEFINE) 13 (?<NAME_PAT>[a-z]+) 14 (?<ADDRESS_PAT>\d+) 15 )/x 16 /^(?:((.)(?1)\2|)|((.)(?3)\4|.))$/i 17 18 #save testsaved1 19 20 # Do it again for some more patterns. 21 22 /(*MARK:A)(*SKIP:B)(C|X)/mark 23 ** Ignored when compiled pattern is stacked with 'push': mark 24 /(?:(?<n>foo)|(?<n>bar))\k<n>/dupnames 25 26 #save testsaved2 27 #pattern -push 28 29 # Reload the patterns, then pop them one by one and check them. 30 31 #load testsaved1 32 #load testsaved2 33 34 #pop info 35 Capturing subpattern count = 2 36 Max back reference = 2 37 Named capturing subpatterns: 38 n 1 39 n 2 40 Options: dupnames 41 Starting code units: b f 42 Subject length lower bound = 6 43 foofoo 44 0: foofoo 45 1: foo 46 barbar 47 0: barbar 48 1: <unset> 49 2: bar 50 51 #pop mark 52 C 53 0: C 54 1: C 55 MK: A 56 \= Expect no match 57 D 58 No match, mark = A 59 60 #pop 61 AmanaplanacanalPanama 62 0: AmanaplanacanalPanama 63 1: <unset> 64 2: <unset> 65 3: AmanaplanacanalPanama 66 4: A 67 68 #pop info 69 Capturing subpattern count = 4 70 Named capturing subpatterns: 71 ADDR 2 72 ADDRESS_PAT 4 73 NAME 1 74 NAME_PAT 3 75 Options: extended 76 Subject length lower bound = 3 77 metcalfe 33 78 0: metcalfe 33 79 1: metcalfe 80 2: 33 81 82 # Check for an error when different tables are used. 83 84 /abc/push,tables=1 85 /xyz/push,tables=2 86 #save testsaved1 87 Serialization failed: error -30: patterns do not all use the same character tables 88 89 #pop 90 xyz 91 0: xyz 92 93 #pop 94 abc 95 0: abc 96 97 #pop should give an error 98 ** Can't pop off an empty stack 99 pqr 100 101 /abcd/pushcopy 102 abcd 103 0: abcd 104 105 #pop 106 abcd 107 0: abcd 108 109 #pop should give an error 110 ** Can't pop off an empty stack 111 112 /abcd/push 113 #popcopy 114 abcd 115 0: abcd 116 117 #pop 118 abcd 119 0: abcd 120 121 /abcd/push 122 #save testsaved1 123 #pop should give an error 124 ** Can't pop off an empty stack 125 126 #load testsaved1 127 #popcopy 128 abcd 129 0: abcd 130 131 #pop 132 abcd 133 0: abcd 134 135 #pop should give an error 136 ** Can't pop off an empty stack 137 138 # End of testinput20 139