Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Reorder tests to be in method order

  • Loading branch information...
commit da4941bbe66c19c5b7d27d4d114f4baea74d3a70 1 parent cb83c29
authored April 03, 2013
2  ext/u/rb_u.c
@@ -33,7 +33,7 @@ uint32_t
33 33
 _rb_u_dref(const char *str, const char *end)
34 34
 {
35 35
         if (str >= end)
36  
-                rb_u_raise(rb_eArgError, "String is empty");
  36
+                rb_u_raise(rb_eArgError, "string is empty");
37 37
 
38 38
         uint32_t c = u_dref_validated_n(str, end - str);
39 39
         switch (c) {
1,778  test/unit/u/string.rb
... ...
@@ -1,97 +1,129 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 Expectations do
4  
-  expect nil do ''.u[0, -2] end
5  
-  expect nil do ''.u[0, -1] end
  4
+  expect true do 'äbc'.u.valid_encoding? end
  5
+  expect true do "äbc\0def".u.valid_encoding? end
  6
+  expect false do "\xc3bc".u.valid_encoding? end
6 7
 
7  
-  expect ''.u do ''.u[0, 0] end
8  
-  expect ''.u do ''.u[0, 1] end
9  
-  expect ''.u do ''.u[0, 2] end
  8
+  expect true do ''.u.alnum? end
  9
+  expect true do 'a'.u.alnum? end
  10
+  expect true do 'ab'.u.alnum? end
  11
+  expect false do '/'.u.alnum? end
10 12
 
11  
-  expect nil do ''.u[-1, -2] end
12  
-  expect nil do ''.u[-1, -1] end
13  
-  expect nil do ''.u[-1, 0] end
14  
-  expect nil do ''.u[-1, 1] end
15  
-  expect nil do ''.u[-1, 2] end
16  
-  expect nil do ''.u[1, -2] end
17  
-  expect nil do ''.u[1, -1] end
18  
-  expect nil do ''.u[1, 0] end
19  
-  expect nil do ''.u[1, 1] end
20  
-  expect nil do ''.u[1, 2] end
  13
+  expect true do ''.u.alpha? end
  14
+  expect true do 'a'.u.alpha? end
  15
+  expect true do 'ab'.u.alpha? end
  16
+  expect false do 'a0'.u.alpha? end
21 17
 
22  
-  expect nil do ''.u[0] end
  18
+  expect true do 'abc'.u.ascii_only? end
  19
+  expect false do 'äbc'.u.ascii_only? end
23 20
 
24  
-  expect 'h'.u do 'hëllö'.u[0] end
25  
-  expect 'ö'.u do 'hëllö'.u[-1] end
26  
-  expect nil do 'hëllö'.u[5] end
27  
-  expect nil do 'hëllö'.u[-6] end
  21
+  expect true do ''.u.assigned? end
  22
+  expect true do 'a'.u.assigned? end
  23
+  expect true do 'ab'.u.assigned? end
  24
+  expect false do [0x0588].pack('U').u.assigned? end
28 25
 
29  
-  expect 'hë'.u do 'hëllö'.u[0, 2] end
30  
-  expect 'lö'.u do 'hëllö'.u[-2, 2] end
31  
-  expect 'lö'.u do 'hëllö'.u[3, 2] end
  26
+  expect true do ''.u.case_ignorable? end
  27
+  expect true do "'".u.case_ignorable? end
  28
+  expect true do "'’".u.case_ignorable? end
  29
+  expect true do [0x0307].pack('U').u.case_ignorable? end
  30
+  expect false do 'a'.u.case_ignorable? end
32 31
 
33  
-  expect 'hël'.u do 'hëllö'.u[0..2] end
34  
-  expect 'hël'.u do 'hëllö'.u[0...3] end
35  
-  expect 'lö'.u do 'hëllö'.u[-2..-1] end
  32
+  expect true do ''.u.cased? end
  33
+  expect true do 'a'.u.cased? end
  34
+  expect true do 'ab'.u.cased? end
  35
+  expect false do '0'.u.cased? end
36 36
 
37  
-  expect 'hë'.u do 'hëllö'.u[/\Ah./u] end
38  
-  expect 'lö'.u do 'hëllö'.u[/.ö\z/u] end
39  
-  expect nil do 'hëllö'.u[/other/u] end
  37
+  expect true do ''.u.cntrl? end
  38
+  expect true do "\0".u.cntrl? end
  39
+  expect true do "\0\1".u.cntrl? end
  40
+  expect false do "a".u.cntrl? end
40 41
 
41  
-  expect 'hë'.u do 'hëllö'.u['hë'.u] end
42  
-  expect 'lö'.u do 'hëllö'.u['lö'.u] end
43  
-  expect 'hë'.u do 'hëllö'.u['hë'] end
44  
-  expect 'lö'.u do 'hëllö'.u['lö'] end
45  
-  expect nil do 'hëllö'.u['other'.u] end
46  
-  expect nil do 'hëllö'.u['other'] end
  42
+  expect true do ''.u.defined? end
  43
+  expect true do 'a'.u.defined? end
  44
+  expect true do 'ab'.u.defined? end
  45
+  expect false do [0x0588].pack('U').u.defined? end
  46
+  # TODO: This raises an error, as we’re using u_aref_char_validated_n for
  47
+  # these functions.  Perhaps use u_aref_char_n and don’t raise errors on
  48
+  # invalid input.
  49
+  # expect false do [0xD800].pack('U').u.defined? end
47 50
 
48  
-  expect 'hë'.u do 'hëllö'.u[/(..)(..)/u, 1] end
49  
-  expect 'll'.u do 'hëllö'.u[/(..)(..)/u, 2] end
50  
-  expect nil do 'hëllö'.u[/(..)(..)/u, 3] end
51  
-  expect 'll'.u do 'hëllö'.u[/(..)(..)/u, -1] end
52  
-  expect 'hë'.u do 'hëllö'.u[/(..)(..)/u, -2] end
53  
-  expect nil do 'hëllö'.u[/(..)(..)/u, -3] end
  51
+  expect true do ''.u.digit? end
  52
+  expect true do '0'.u.digit? end
  53
+  expect true do '01'.u.digit? end
  54
+  expect false do '0a'.u.digit? end
54 55
 
55  
-  expect 'l'.u do 'hëllö'.u[stub(:to_int => 2)] end
  56
+  expect true do 'ss'.u.folded? end
  57
+  expect false do 'ß'.u.folded? end
  58
+  expect true do 'abc\0ß'.u.foldcase.folded? end
56 59
 
57  
-  expect ArgumentError do 'hëllö'.u[1, 2, 3] end
58  
-  expect ArgumentError do 'hëllö'.u[] end
  60
+  expect true do ''.u.graph? end
  61
+  expect true do '0'.u.graph? end
  62
+  expect true do '01'.u.graph? end
  63
+  expect false do "\0".u.graph? end
59 64
 
60  
-  expect result.tainted? do 'a'.u.taint[0] end
61  
-  expect result.untrusted? do 'a'.u.untrust[0] end
62  
-  expect result.tainted? do 'a'.u.taint[0, 1] end
63  
-  expect result.untrusted? do 'a'.u.untrust[0, 1] end
64  
-  expect result.tainted? do 'a'.u.taint[0...1] end
65  
-  expect result.untrusted? do 'a'.u.untrust[0...1] end
66  
-  expect result.tainted? do 'a'.u.taint[/a/] end
67  
-  expect result.untrusted? do 'a'.u.untrust[/a/] end
68  
-  expect result.tainted? do 'a'.u[/a/.taint] end
69  
-  expect result.untrusted? do 'a'.u[/a/.untrust] end
70  
-  expect result.tainted? do 'a'.u[/(a)/.taint, 1] end
71  
-  expect result.untrusted? do 'a'.u[/(a)/.untrust, 1] end
72  
-  expect result.not.tainted? do 'a'.u.taint['a'.u] end
73  
-  expect result.not.untrusted? do 'a'.u.untrust['a'.u] end
74  
-  expect result.not.tainted? do 'a'.u.taint['a'] end
75  
-  expect result.not.untrusted? do 'a'.u.untrust['a'] end
76  
-  expect result.tainted? do 'a'.u['a'.u.taint] end
77  
-  expect result.untrusted? do 'a'.u['a'.u.untrust] end
78  
-  expect result.tainted? do 'a'.u['a'.taint] end
79  
-  expect result.untrusted? do 'a'.u['a'.untrust] end
  65
+  expect true do 'i'.u.lower? end
  66
+  expect true do 'i'.u.lower?('lt') end
  67
+  expect false do 'I'.u.lower? end
  68
+  expect false do 'I'.u.lower?('lt') end
80 69
 
81  
-  expect ArgumentError do '*'.u * -1 end
82  
-  expect ''.u do ''.u * 10 end
83  
-  expect '**********'.u do '*'.u * 10 end
84  
-  # TODO: Test LONG_MAX.
85  
-  expect result.tainted? do ''.u.taint * 10 end
86  
-  expect result.untrusted? do ''.u.untrust * 10 end
  70
+  expect true do ''.u.newline? end
  71
+  expect true do [0x2028].pack('U').u.newline? end
  72
+  expect true do "\r\n".u.newline? end
  73
+  expect false do 'a'.u.newline? end
87 74
 
88  
-  expect 'hëll'.u do 'hëll'.u + ''.u end
89  
-  expect 'ö'.u do ''.u + 'ö'.u end
90  
-  expect 'hëllö'.u do 'hëll'.u + 'ö'.u end
91  
-  expect result.tainted? do ''.u.taint + ''.u end
92  
-  expect result.tainted? do ''.u + ''.u.taint end
93  
-  expect result.not.untrusted? do ''.u.untrust + ''.u end
94  
-  expect result.not.untrusted? do ''.u + ''.u.untrust end
  75
+  expect true do ''.u.print? end
  76
+  expect true do 'a'.u.print? end
  77
+  expect true do 'ab'.u.print? end
  78
+  expect false do "\n".u.print? end
  79
+
  80
+  expect true do ''.u.punct? end
  81
+  expect true do '.'.u.punct? end
  82
+  expect true do '()'.u.punct? end
  83
+  expect false do 'a'.u.punct? end
  84
+
  85
+  expect true do ''.u.soft_dotted? end
  86
+  expect true do 'i'.u.soft_dotted? end
  87
+  expect true do 'ij'.u.soft_dotted? end
  88
+  expect false do 'a'.u.soft_dotted? end
  89
+
  90
+  expect true do ''.u.space? end
  91
+  expect true do ' '.u.space? end
  92
+  expect true do " \t\n".u.space? end
  93
+  expect false do 'a'.u.space? end
  94
+
  95
+  expect false do 'i'.u.title? end
  96
+  expect false do 'I'.u.title? end
  97
+  expect false do 'DZ'.u.title? end
  98
+  expect true do 'Dz'.u.title? end
  99
+
  100
+  expect false do 'i'.u.upper? end
  101
+  expect false do 'i'.u.upper?('lt') end
  102
+  expect false do 'i'.u.upper?('tr') end
  103
+  expect true do 'I'.u.upper? end
  104
+  expect true do 'I'.u.upper?('lt') end
  105
+  expect true do 'I'.u.upper?('tr') end
  106
+
  107
+  expect true do ''.u.wide? end
  108
+  expect true do '豈'.u.wide? end
  109
+  expect true do '豈豈'.u.wide? end
  110
+  expect false do 'a'.u.wide? end
  111
+
  112
+  expect true do ''.u.wide_cjk? end
  113
+  expect true do '豈'.u.wide_cjk? end
  114
+  expect true do '豈豈'.u.wide_cjk? end
  115
+  expect true do '豈♣'.u.wide_cjk? end
  116
+  expect false do 'a'.u.wide_cjk? end
  117
+
  118
+  expect true do ''.u.xdigit? end
  119
+  expect true do '0'.u.xdigit? end
  120
+  expect true do '0a'.u.xdigit? end
  121
+  expect false do 'g'.u.xdigit? end
  122
+
  123
+  expect true do ''.u.zero_width? end
  124
+  expect true do [0x200b].pack('U').u.zero_width? end
  125
+  expect true do [0x200b, 0x1160].pack('U*').u.zero_width? end
  126
+  expect false do 'a'.u.zero_width? end
95 127
 
96 128
   expect TypeError do 'abc'.u =~ 'abc' end
97 129
   expect TypeError do 'abc'.u =~ 'abc'.u end
@@ -112,43 +144,303 @@
112 144
   expect result.tainted? do 'abc'.u.match('a'.taint) end
113 145
   expect result.untrusted? do 'abc'.u.match('a'.untrust) end
114 146
 
115  
-  # TODO: Should <=>, ==, ===, eql?, and casecmp use collation or not?  When
116  
-  # should collation be used?  #collate and #collation_key?
117  
-
118  
-  expect true do ''.u.alnum? end
119  
-  expect true do 'a'.u.alnum? end
120  
-  expect true do 'ab'.u.alnum? end
121  
-  expect false do '/'.u.alnum? end
  147
+  expect result.to.be.empty? do ''.u end
  148
+  expect result.not.to.be.empty? do 'not'.u end
122 149
 
123  
-  expect true do ''.u.alpha? end
124  
-  expect true do 'a'.u.alpha? end
125  
-  expect true do 'ab'.u.alpha? end
126  
-  expect false do 'a0'.u.alpha? end
  150
+  expect result.to.end_with?('c') do 'abc'.u end
  151
+  expect result.not.to.end_with?('d') do 'abc'.u end
  152
+  expect result.to.end_with?('ä') do 'cbä'.u end
  153
+  expect result.not.to.end_with?('äb') do 'cbä'.u end
  154
+  expect result.to.end_with?('a', 'ä') do 'cbä'.u end
  155
+  expect result.not.to.end_with? do 'cbä'.u end
127 156
 
128  
-  expect true do ''.u.assigned? end
129  
-  expect true do 'a'.u.assigned? end
130  
-  expect true do 'ab'.u.assigned? end
131  
-  expect false do [0x0588].pack('U').u.assigned? end
  157
+  expect result.to.include?('f'.u) do 'fööbär'.u end
  158
+  expect result.to.include?('föö'.u) do 'fööbär'.u end
  159
+  expect result.to.include?('bär'.u) do 'fööbär'.u end
  160
+  expect result.not.to.include?('bäz'.u) do 'fööbär'.u end
  161
+  expect result.not.to.include?('z'.u) do 'fööbär'.u end
132 162
 
133  
-  expect true do 'abc'.u.ascii_only? end
134  
-  expect false do 'äbc'.u.ascii_only? end
  163
+  expect 0 do 'hëllö'.u.index('') end
  164
+  expect 0 do 'hëllö'.u.index('h') end
  165
+  expect 4 do 'hëllö'.u.index('ö') end
  166
+  expect 1 do 'hëllö'.u.index('ëll') end
  167
+  expect 2 do 'hëllö'.u.index(/ll/u) end
  168
+  expect nil do 'hëllö'.u.index('hëllö!') end
  169
+  expect nil do 'hëllö'.u.index('z') end
  170
+  expect nil do 'hëllö'.u.index(/z./u) end
  171
+  expect 3 do 'hëllö'.u.index('l', 3) end
  172
+  expect 3 do 'hëllö'.u.index(/l./u, 3) end
  173
+  expect nil do 'hëllö'.u.index('hëllö!', 3) end
  174
+  expect nil do 'hëllö'.u.index('z', 3) end
  175
+  expect nil do 'hëllö'.u.index(/z./u, 3) end
  176
+  expect 2 do 'hëllö'.u.index(stub(:to_str => 'llö')) end
  177
+  expect TypeError do 'hëllö'.u.index(Object.new) end
  178
+  expect nil do 'föö'.u.index(//, -100) end
  179
+  expect nil do 'föö'.u.index(//, -100); $~ end
135 180
 
136  
-  expect :open_punctuation do '('.u.line_break end
137  
-  expect :close_parenthesis do ')'.u.line_break end
  181
+  expect 5 do 'hëllö'.u.rindex('') end
  182
+  expect 3 do 'hëllö'.u.rindex('l') end
  183
+  expect 6 do 'ëll, hëllö'.u.rindex('ëll') end
  184
+  expect 7 do 'ëll, hëllö'.u.rindex(/ll./u) end
  185
+  expect nil do 'hëllö'.u.rindex('hëllö!') end
  186
+  expect nil do 'hëllö'.u.rindex('z') end
  187
+  expect nil do 'hëllö'.u.rindex(/z./u) end
  188
+  expect 3 do 'hëllö,lö'.u.rindex('l', 3) end
  189
+  expect 3 do 'hëllö,lö'.u.rindex(/l./u, 3) end
  190
+  expect nil do 'hëllö,lö'.u.rindex('hëllö!', 3) end
  191
+  expect nil do 'hëllö,lö'.u.rindex('z', 3) end
  192
+  expect nil do 'hëllö,lö'.u.rindex(/z./u, 3) end
  193
+  expect 6 do 'fööbarbarbaz'.u.rindex(stub(:to_str => 'bar')) end
  194
+  expect TypeError do 'hëllö'.u.rindex(Object.new) end
  195
+  expect nil do 'föö'.u.rindex(//, -100) end
  196
+  expect nil do 'föö'.u.rindex(//, -100); $~ end
138 197
 
139  
-  expect :cr do "\r".u.grapheme_break end
140  
-  expect :other do 'a'.u.grapheme_break end
  198
+  expect result.to.start_with?('a') do 'abc'.u end
  199
+  expect result.not.to.start_with?('b') do 'abc'.u end
  200
+  expect result.to.start_with?('ä') do 'äbc'.u end
  201
+  expect result.not.to.start_with?('bc') do 'äbc'.u end
  202
+  expect result.to.start_with?('a', 'ä') do 'äbc'.u end
  203
+  expect result.not.to.start_with? do 'äbc'.u end
  204
+
  205
+  expect 1 do 'あB'.u.casecmp('あa') end
  206
+  expect 1 do 'あB'.u.casecmp('あa'.u) end
  207
+
  208
+  expect ''.u do "\0".u.collation_key end
  209
+  expect 'äbcdëf'.u do 'äbcdëf'.u.collation_key end
  210
+  expect 'äbcdëf'.u do "äbc\0dëf".u.collation_key end
  211
+  expect result.tainted? do ''.u.taint.collation_key end
  212
+  expect result.untrusted? do ''.u.untrust.collation_key end
  213
+
  214
+  expect 0 do 'a'.u.combining_class end
  215
+  expect 230 do [0x0307].pack('U').u.combining_class end
  216
+
  217
+  expect :letter_uppercase do 'A'.u.general_category end
  218
+  expect :punctuation_other do '.'.u.general_category end
  219
+  expect :symbol_currency do '$'.u.general_category end
  220
+  expect :separator_space do ' '.u.general_category end
  221
+
  222
+  expect :cr do "\r".u.grapheme_break end
  223
+  expect :other do 'a'.u.grapheme_break end
  224
+
  225
+  expect :open_punctuation do '('.u.line_break end
  226
+  expect :close_parenthesis do ')'.u.line_break end
  227
+
  228
+  expect ArgumentError do [0x002A, 0x1CED].pack('U*').u.script end
  229
+  expect :common do [0x002A].pack('U').u.script end
  230
+  expect :inherited do [0x1CED].pack('U').u.script end
  231
+  expect :inherited do [0x0670].pack('U').u.script end
  232
+  expect :arabic do [0x060D].pack('U').u.script end
  233
+  expect :armenian do [0x0559].pack('U').u.script end
  234
+  expect :bengali do [0x09CD].pack('U').u.script end
  235
+  expect :bopomofo do [0x31B6].pack('U').u.script end
  236
+  expect :cherokee do [0x13A2].pack('U').u.script end
  237
+  expect :coptic do [0x2CFD].pack('U').u.script end
  238
+  expect :cyrillic do [0x0482].pack('U').u.script end
  239
+  expect :deseret do [0x10401].pack('U').u.script end
  240
+  expect :devanagari do [0x094D].pack('U').u.script end
  241
+  expect :ethiopic do [0x1258].pack('U').u.script end
  242
+  expect :georgian do [0x10FC].pack('U').u.script end
  243
+  expect :gothic do [0x10341].pack('U').u.script end
  244
+  expect :greek do [0x0375].pack('U').u.script end
  245
+  expect :gujarati do [0x0A83].pack('U').u.script end
  246
+  expect :gurmukhi do [0x0A3C].pack('U').u.script end
  247
+  expect :han do [0x3005].pack('U').u.script end
  248
+  expect :hangul do [0x1100].pack('U').u.script end
  249
+  expect :hebrew do [0x05BF].pack('U').u.script end
  250
+  expect :hiragana do [0x309F].pack('U').u.script end
  251
+  expect :kannada do [0x0CBC].pack('U').u.script end
  252
+  expect :katakana do [0x30FF].pack('U').u.script end
  253
+  expect :khmer do [0x17DD].pack('U').u.script end
  254
+  expect :lao do [0x0EDD].pack('U').u.script end
  255
+  expect :latin do [0x0061].pack('U').u.script end
  256
+  expect :malayalam do [0x0D3D].pack('U').u.script end
  257
+  expect :mongolian do [0x1843].pack('U').u.script end
  258
+  expect :myanmar do [0x1031].pack('U').u.script end
  259
+  expect :ogham do [0x169C].pack('U').u.script end
  260
+  expect :old_italic do [0x10322].pack('U').u.script end
  261
+  expect :oriya do [0x0B3C].pack('U').u.script end
  262
+  expect :runic do [0x16EF].pack('U').u.script end
  263
+  expect :sinhala do [0x0DBD].pack('U').u.script end
  264
+  expect :syriac do [0x0711].pack('U').u.script end
  265
+  expect :tamil do [0x0B82].pack('U').u.script end
  266
+  expect :telugu do [0x0C03].pack('U').u.script end
  267
+  expect :thaana do [0x07B1].pack('U').u.script end
  268
+  expect :thai do [0x0E31].pack('U').u.script end
  269
+  expect :tibetan do [0x0FD4].pack('U').u.script end
  270
+  expect :canadian_aboriginal do [0x1400].pack('U').u.script end
  271
+  expect :canadian_aboriginal do [0x1401].pack('U').u.script end
  272
+  expect :yi do [0xA015].pack('U').u.script end
  273
+  expect :tagalog do [0x1700].pack('U').u.script end
  274
+  expect :hanunoo do [0x1720].pack('U').u.script end
  275
+  expect :buhid do [0x1740].pack('U').u.script end
  276
+  expect :tagbanwa do [0x1760].pack('U').u.script end
  277
+  expect :braille do [0x2800].pack('U').u.script end
  278
+  expect :cypriot do [0x10808].pack('U').u.script end
  279
+  expect :limbu do [0x1932].pack('U').u.script end
  280
+  expect :osmanya do [0x10480].pack('U').u.script end
  281
+  expect :shavian do [0x10450].pack('U').u.script end
  282
+  expect :linear_b do [0x10000].pack('U').u.script end
  283
+  expect :tai_le do [0x1950].pack('U').u.script end
  284
+  expect :ugaritic do [0x1039F].pack('U').u.script end
  285
+  expect :new_tai_lue do [0x1980].pack('U').u.script end
  286
+  expect :buginese do [0x1A1F].pack('U').u.script end
  287
+  expect :glagolitic do [0x2C00].pack('U').u.script end
  288
+  expect :tifinagh do [0x2D6F].pack('U').u.script end
  289
+  expect :syloti_nagri do [0xA800].pack('U').u.script end
  290
+  expect :old_persian do [0x103D0].pack('U').u.script end
  291
+  expect :kharoshthi do [0x10A3F].pack('U').u.script end
  292
+  expect :unknown do [0x1111111].pack('U').u.script end
  293
+  expect :balinese do [0x1B04].pack('U').u.script end
  294
+  expect :cuneiform do [0x12000].pack('U').u.script end
  295
+  expect :phoenician do [0x10900].pack('U').u.script end
  296
+  expect :phags_pa do [0xA840].pack('U').u.script end
  297
+  expect :nko do [0x07C0].pack('U').u.script end
  298
+  expect :kayah_li do [0xA900].pack('U').u.script end
  299
+  expect :lepcha do [0x1C00].pack('U').u.script end
  300
+  expect :rejang do [0xA930].pack('U').u.script end
  301
+  expect :sundanese do [0x1B80].pack('U').u.script end
  302
+  expect :saurashtra do [0xA880].pack('U').u.script end
  303
+  expect :cham do [0xAA00].pack('U').u.script end
  304
+  expect :ol_chiki do [0x1C50].pack('U').u.script end
  305
+  expect :vai do [0xA500].pack('U').u.script end
  306
+  expect :carian do [0x102A0].pack('U').u.script end
  307
+  expect :lycian do [0x10280].pack('U').u.script end
  308
+  expect :lydian do [0x1093F].pack('U').u.script end
  309
+  expect :avestan do [0x10B00].pack('U').u.script end
  310
+  expect :bamum do [0xA6A0].pack('U').u.script end
  311
+  expect :egyptian_hieroglyphs do [0x13000].pack('U').u.script end
  312
+  expect :imperial_aramaic do [0x10840].pack('U').u.script end
  313
+  expect :inscriptional_pahlavi do [0x10B60].pack('U').u.script end
  314
+  expect :inscriptional_parthian do [0x10B40].pack('U').u.script end
  315
+  expect :javanese do [0xA980].pack('U').u.script end
  316
+  expect :kaithi do [0x11082].pack('U').u.script end
  317
+  expect :lisu do [0xA4D0].pack('U').u.script end
  318
+  expect :meetei_mayek do [0xABE5].pack('U').u.script end
  319
+  expect :old_south_arabian do [0x10A60].pack('U').u.script end
  320
+  expect :old_turkic do [0x10C00].pack('U').u.script end
  321
+  expect :samaritan do [0x0800].pack('U').u.script end
  322
+  expect :tai_tham do [0x1A20].pack('U').u.script end
  323
+  expect :tai_viet do [0xAA80].pack('U').u.script end
  324
+  expect :batak do [0x1BC0].pack('U').u.script end
  325
+  expect :brahmi do [0x11000].pack('U').u.script end
  326
+  expect :mandaic do [0x0840].pack('U').u.script end
  327
+
  328
+  expect :aletter do 'a'.u.word_break end
141 329
 
142 330
   expect 4 do 'äbc'.u.bytesize end
143 331
   expect 9 do "äbc\0dëf".u.bytesize end
144 332
 
  333
+  expect 0 do ''.u.length end
  334
+  expect 4 do '1234'.u.length end
  335
+  expect 6 do "1234\r\n".u.length end
  336
+  expect 7 do "\0011234\r\n".u.length end
  337
+  expect 5 do 'hëllö'.u.length end
  338
+  expect 6 do "\0hëllö".u.length end
  339
+  # TODO Why not throw an error here?
  340
+  expect 11 do "hëllö\0agäin\303".u.length end
  341
+
  342
+  expect 0 do ''.u.size end
  343
+  expect 4 do '1234'.u.size end
  344
+  expect 6 do "1234\r\n".u.size end
  345
+  expect 7 do "\0011234\r\n".u.size end
  346
+  expect 5 do 'hëllö'.u.size end
  347
+  expect 6 do "\0hëllö".u.size end
  348
+  # TODO Why not throw an error here?
  349
+  expect 11 do "hëllö\0agäin\303".u.size end
  350
+
  351
+  expect 0 do ''.u.width end
  352
+  expect 1 do 'a'.u.width end
  353
+  expect 1 do "a\xcc\x87".u.width end
  354
+  expect 2 do '豈'.u.width end
  355
+  expect 3 do 'a豈'.u.width end
  356
+
  357
+  expect [0x61, 0x62, 0x63, 0x00, 0x64, 0xc3, 0xab, 0x66] do "abc\0dëf".u.bytes.to_a end
  358
+
  359
+  expect ['h'.u, 'ë'.u, 'l'.u, 'l'.u, 'ö'.u] do 'hëllö'.u.chars.to_a end
  360
+  expect result.tainted? do 'a'.u.taint.chars.first end
  361
+  expect result.untrusted? do 'a'.u.untrust.chars.first end
  362
+
  363
+  expect [0x0068, 0x00eb, 0x006c, 0x006c, 0x00f6] do 'hëllö'.u.codepoints.to_a end
  364
+
  365
+  expect ["hello\n".u, 'world'.u] do with_global(:$/, "\n"){ "hello\nworld".u.lines.to_a } end
  366
+  expect ["hello\n\n\n".u, 'world'.u] do "hello\n\n\nworld".u.lines('').to_a end
  367
+  expect ['hello!'.u, 'world'.u] do with_global(:$/, '!'){ 'hello!world'.u.lines.to_a } end
  368
+  expect ["hello\nworld".u] do with_global(:$/, nil){ "hello\nworld".u.lines.to_a } end
  369
+  expect ['hëll hëllö'.u, ' world'.u] do 'hëll hëllö world'.u.lines('llö').to_a end
  370
+  expect ["hello\0".u, 'world'.u] do "hello\0world".u.lines("\0").to_a end
  371
+  expect result.tainted? do 'a'.u.taint.lines.first end
  372
+  expect result.untrusted? do 'a'.u.untrust.lines.first end
  373
+
  374
+  expect nil do ''.u[0, -2] end
  375
+  expect nil do ''.u[0, -1] end
  376
+  expect ''.u do ''.u[0, 0] end
  377
+  expect ''.u do ''.u[0, 1] end
  378
+  expect ''.u do ''.u[0, 2] end
  379
+  expect nil do ''.u[-1, -2] end
  380
+  expect nil do ''.u[-1, -1] end
  381
+  expect nil do ''.u[-1, 0] end
  382
+  expect nil do ''.u[-1, 1] end
  383
+  expect nil do ''.u[-1, 2] end
  384
+  expect nil do ''.u[1, -2] end
  385
+  expect nil do ''.u[1, -1] end
  386
+  expect nil do ''.u[1, 0] end
  387
+  expect nil do ''.u[1, 1] end
  388
+  expect nil do ''.u[1, 2] end
  389
+  expect nil do ''.u[0] end
  390
+  expect 'h'.u do 'hëllö'.u[0] end
  391
+  expect 'ö'.u do 'hëllö'.u[-1] end
  392
+  expect nil do 'hëllö'.u[5] end
  393
+  expect nil do 'hëllö'.u[-6] end
  394
+  expect 'hë'.u do 'hëllö'.u[0, 2] end
  395
+  expect 'lö'.u do 'hëllö'.u[-2, 2] end
  396
+  expect 'lö'.u do 'hëllö'.u[3, 2] end
  397
+  expect 'hël'.u do 'hëllö'.u[0..2] end
  398
+  expect 'hël'.u do 'hëllö'.u[0...3] end
  399
+  expect 'lö'.u do 'hëllö'.u[-2..-1] end
  400
+  expect 'hë'.u do 'hëllö'.u[/\Ah./u] end
  401
+  expect 'lö'.u do 'hëllö'.u[/.ö\z/u] end
  402
+  expect nil do 'hëllö'.u[/other/u] end
  403
+  expect 'hë'.u do 'hëllö'.u['hë'.u] end
  404
+  expect 'lö'.u do 'hëllö'.u['lö'.u] end
  405
+  expect 'hë'.u do 'hëllö'.u['hë'] end
  406
+  expect 'lö'.u do 'hëllö'.u['lö'] end
  407
+  expect nil do 'hëllö'.u['other'.u] end
  408
+  expect nil do 'hëllö'.u['other'] end
  409
+  expect 'hë'.u do 'hëllö'.u[/(..)(..)/u, 1] end
  410
+  expect 'll'.u do 'hëllö'.u[/(..)(..)/u, 2] end
  411
+  expect nil do 'hëllö'.u[/(..)(..)/u, 3] end
  412
+  expect 'll'.u do 'hëllö'.u[/(..)(..)/u, -1] end
  413
+  expect 'hë'.u do 'hëllö'.u[/(..)(..)/u, -2] end
  414
+  expect nil do 'hëllö'.u[/(..)(..)/u, -3] end
  415
+  expect 'l'.u do 'hëllö'.u[stub(:to_int => 2)] end
  416
+  expect ArgumentError do 'hëllö'.u[1, 2, 3] end
  417
+  expect ArgumentError do 'hëllö'.u[] end
  418
+  expect result.tainted? do 'a'.u.taint[0] end
  419
+  expect result.untrusted? do 'a'.u.untrust[0] end
  420
+  expect result.tainted? do 'a'.u.taint[0, 1] end
  421
+  expect result.untrusted? do 'a'.u.untrust[0, 1] end
  422
+  expect result.tainted? do 'a'.u.taint[0...1] end
  423
+  expect result.untrusted? do 'a'.u.untrust[0...1] end
  424
+  expect result.tainted? do 'a'.u.taint[/a/] end
  425
+  expect result.untrusted? do 'a'.u.untrust[/a/] end
  426
+  expect result.tainted? do 'a'.u[/a/.taint] end
  427
+  expect result.untrusted? do 'a'.u[/a/.untrust] end
  428
+  expect result.tainted? do 'a'.u[/(a)/.taint, 1] end
  429
+  expect result.untrusted? do 'a'.u[/(a)/.untrust, 1] end
  430
+  expect result.not.tainted? do 'a'.u.taint['a'.u] end
  431
+  expect result.not.untrusted? do 'a'.u.untrust['a'.u] end
  432
+  expect result.not.tainted? do 'a'.u.taint['a'] end
  433
+  expect result.not.untrusted? do 'a'.u.untrust['a'] end
  434
+  expect result.tainted? do 'a'.u['a'.u.taint] end
  435
+  expect result.untrusted? do 'a'.u['a'.u.untrust] end
  436
+  expect result.tainted? do 'a'.u['a'.taint] end
  437
+  expect result.untrusted? do 'a'.u['a'.untrust] end
  438
+
145 439
   expect nil do ''.u.byteslice(0, -2) end
146 440
   expect nil do ''.u.byteslice(0, -1) end
147  
-
148 441
   expect ''.u do ''.u.byteslice(0, 0) end
149 442
   expect ''.u do ''.u.byteslice(0, 1) end
150 443
   expect ''.u do ''.u.byteslice(0, 2) end
151  
-
152 444
   expect nil do ''.u.byteslice(-1, -2) end
153 445
   expect nil do ''.u.byteslice(-1, -1) end
154 446
   expect nil do ''.u.byteslice(-1, 0) end
@@ -159,27 +451,20 @@
159 451
   expect nil do ''.u.byteslice(1, 0) end
160 452
   expect nil do ''.u.byteslice(1, 1) end
161 453
   expect nil do ''.u.byteslice(1, 2) end
162  
-
163 454
   expect nil do ''.u.byteslice(0) end
164  
-
165 455
   expect 'h'.u do 'hëllö'.u.byteslice(0) end
166 456
   expect "\xb6".u do 'hëllö'.u.byteslice(-1) end
167 457
   expect nil do 'hëllö'.u.byteslice(7) end
168 458
   expect nil do 'hëllö'.u.byteslice(-8) end
169  
-
170 459
   expect "h\xc3".u do 'hëllö'.u.byteslice(0, 2) end
171 460
   expect 'ö'.u do 'hëllö'.u.byteslice(-2, 2) end
172 461
   expect 'll'.u do 'hëllö'.u.byteslice(3, 2) end
173  
-
174 462
   expect 'hë'.u do 'hëllö'.u.byteslice(0..2) end
175 463
   expect 'hë'.u do 'hëllö'.u.byteslice(0...3) end
176 464
   expect 'ö'.u do 'hëllö'.u.byteslice(-2..-1) end
177  
-
178 465
   expect 'l'.u do 'hëllö'.u.byteslice(stub(:to_int => 3)) end
179  
-
180 466
   expect ArgumentError do 'hëllö'.u.byteslice(1, 2, 3) end
181 467
   expect ArgumentError do 'hëllö'.u.byteslice() end
182  
-
183 468
   expect result.tainted? do 'a'.u.taint.byteslice(0) end
184 469
   expect result.untrusted? do 'a'.u.untrust.byteslice(0) end
185 470
   expect result.tainted? do 'a'.u.taint.byteslice(0, 1) end
@@ -187,75 +472,31 @@
187 472
   expect result.tainted? do 'a'.u.taint.byteslice(0...1) end
188 473
   expect result.untrusted? do 'a'.u.untrust.byteslice(0...1) end
189 474
 
190  
-  expect 1 do 'あB'.u.casecmp('あa') end
191  
-  expect 1 do 'あB'.u.casecmp('あa'.u) end
  475
+  expect 'hello'.u do 'hello'.u.chomp("\n") end
  476
+  expect 'hello'.u do "hello\n".u.chomp("\n") end
  477
+  expect 'hello'.u do with_global(:$/, "\n"){ 'hello'.u.chomp } end
  478
+  expect 'hello'.u do with_global(:$/, "\n"){ "hello\n".u.chomp } end
  479
+  expect 'hello'.u do with_global(:$/, '!'){ 'hello'.u.chomp } end
  480
+  expect 'hello'.u do with_global(:$/, '!'){ 'hello!'.u.chomp } end
  481
+  expect 'hello!!'.u do 'hello!!!'.u.chomp('!') end
  482
+  expect "hello\r\n".u do "hello\r\n\r\n".u.chomp("\n") end
  483
+  expect 'hello'.u do "hello\r".u.chomp("\n") end
  484
+  expect 'hello'.u do "hello\r\n".u.chomp('') end
  485
+  expect "hello".u do "hello\r\n\r\n".u.chomp('') end
  486
+  # NOTE This differs from Ruby because U treats \r as a newline character and
  487
+  # thus removes it.
  488
+  expect 'hello'.u do "hello\r".u.chomp('') end
  489
+  expect 'a'.u do 'aā'.u.chomp('ā') end
  490
+  expect result.tainted? do 'hello'.u.taint.chomp end
  491
+  expect result.untrusted? do 'hello'.u.untrust.chomp end
192 492
 
193  
-  expect true do ''.u.cased? end
194  
-  expect true do 'a'.u.cased? end
195  
-  expect true do 'ab'.u.cased? end
196  
-  expect false do '0'.u.cased? end
197  
-
198  
-  expect true do ''.u.case_ignorable? end
199  
-  expect true do "'".u.case_ignorable? end
200  
-  expect true do "'’".u.case_ignorable? end
201  
-  expect true do [0x0307].pack('U').u.case_ignorable? end
202  
-  expect false do 'a'.u.case_ignorable? end
203  
-
204  
-  expect 'hëllö'.u do 'hëllö'.u.center(4) end
205  
-  expect '   hëllö   '.u do 'hëllö'.u.center(11) end
206  
-  expect 'ababaababa'.u do ''.u.center(10, 'ab') end
207  
-  expect 'ababaababab'.u do ''.u.center(11, 'ab') end
208  
-  expect 'あ3あ'.u do '3'.u.center(5, 'あ') end
209  
-  expect ArgumentError.new('zero-width padding') do '3'.u.center(2, '') end
210  
-  expect 'あ3あ'.u do '3'.u.center(5, 'あ ') end
211  
-  expect 'あ3あ '.u do '3'.u.center(6, 'あ ') end
212  
-  expect 'あ 3あ '.u do '3'.u.center(7, 'あ ') end
213  
-  expect ArgumentError.new('padding is too wide to complete rounding (2 > 1)') do '3'.u.center(4, 'あ') end
214  
-  # TODO: Adjust this to LONG_MAX in Ruby
215  
-#  expect ArgumentError do ''.u.center(9223372036854775807) end
216  
-
217  
-  expect result.tainted? do 'a'.u.taint.center(1) end
218  
-  expect result.untrusted? do 'a'.u.untrust.center(1) end
219  
-  expect result.tainted? do 'a'.u.taint.center(3) end
220  
-  expect result.untrusted? do 'a'.u.untrust.center(3) end
221  
-  expect result.not.tainted? do 'a'.u.center(1, ' '.taint) end
222  
-  expect result.not.untrusted? do 'a'.u.center(1, ' '.untrust) end
223  
-  expect result.tainted? do 'a'.u.taint.center(3, ' '.taint) end
224  
-  expect result.untrusted? do 'a'.u.untrust.center(3, ' '.untrust) end
225  
-
226  
-  expect 'hello'.u do 'hello'.u.chomp("\n") end
227  
-  expect 'hello'.u do "hello\n".u.chomp("\n") end
228  
-  expect 'hello'.u do
229  
-    saved_rs = $/; $/ = "\n"; begin 'hello'.u.chomp ensure; $/ = saved_rs end
230  
-  end
231  
-  expect 'hello'.u do
232  
-    saved_rs = $/; $/ = "\n"; begin "hello\n".u.chomp ensure; $/ = saved_rs end
233  
-  end
234  
-  expect 'hello'.u do
235  
-    saved_rs = $/; $/ = '!'; begin "hello".u.chomp ensure; $/ = saved_rs end
236  
-  end
237  
-  expect 'hello'.u do
238  
-    saved_rs = $/; $/ = '!'; begin "hello!".u.chomp ensure; $/ = saved_rs end
239  
-  end
240  
-  expect 'hello!!'.u do "hello!!!".u.chomp('!') end
241  
-  expect "hello\r\n".u do "hello\r\n\r\n".u.chomp("\n") end
242  
-  expect 'hello'.u do "hello\r".u.chomp("\n") end
243  
-  expect 'hello'.u do "hello\r\n".u.chomp('') end
244  
-  expect "hello".u do "hello\r\n\r\n".u.chomp('') end
245  
-  # NOTE: This differs from Ruby because U treats \r as a newline character and
246  
-  # thus removes it.
247  
-  expect 'hello'.u do "hello\r".u.chomp('') end
248  
-  expect 'a'.u do 'aā'.u.chomp('ā') end
249  
-  expect result.tainted? do 'hello'.u.taint.chomp end
250  
-  expect result.untrusted? do 'hello'.u.untrust.chomp end
251  
-
252  
-  expect 'hell'.u do 'hellö'.u.chop end
253  
-  expect 'hellö'.u do "hellö\r\n".u.chop end
254  
-  expect "hellö\n".u do "hellö\n\r".u.chop end
255  
-  expect ''.u do ''.u.chop end
256  
-  expect ''.u do "\r\n".u.chop end
257  
-  expect result.tainted? do 'hello'.u.taint.chop end
258  
-  expect result.untrusted? do 'hello'.u.untrust.chop end
  493
+  expect 'hell'.u do 'hellö'.u.chop end
  494
+  expect 'hellö'.u do "hellö\r\n".u.chop end
  495
+  expect "hellö\n".u do "hellö\n\r".u.chop end
  496
+  expect ''.u do ''.u.chop end
  497
+  expect ''.u do "\r\n".u.chop end
  498
+  expect result.tainted? do 'hello'.u.taint.chop end
  499
+  expect result.untrusted? do 'hello'.u.untrust.chop end
259 500
 
260 501
   expect ''.u do ''.u.chr end
261 502
   expect 'ä'.u do 'ä'.u.chr end
@@ -263,174 +504,312 @@
263 504
   expect result.tainted? do ''.u.taint.chr end
264 505
   expect result.untrusted? do ''.u.untrust.chr end
265 506
 
266  
-  expect true do ''.u.cntrl? end
267  
-  expect true do "\0".u.cntrl? end
268  
-  expect true do "\0\1".u.cntrl? end
269  
-  expect false do "a".u.cntrl? end
270  
-
271  
-  expect 0 do 'a'.u.combining_class end
272  
-  expect 230 do [0x0307].pack('U').u.combining_class end
  507
+  expect 0x00c3 do 'äbc'.u.getbyte(0) end
  508
+  expect 0x00a4 do 'äbc'.u.getbyte(1) end
  509
+  expect nil do 'äbc'.u.getbyte(4) end
  510
+  expect 0x00a4 do 'äbc'.u.getbyte(-3) end
  511
+  expect 0x00c3 do 'äbc'.u.getbyte(-4) end
  512
+  expect nil do 'äbc'.u.getbyte(-5) end
273 513
 
274  
-  expect 5 do 'hëllö wörld'.u.count('lö') end
275  
-  expect 3 do 'hëllö wörld'.u.count('l', 'lö') end
276  
-  expect 2 do 'hëllö wörld'.u.count('lö', 'ö') end
277  
-  expect 4 do 'hëllö wörld'.u.count('hëllö', '^l') end
278  
-  expect 3 do 'hëllö wörld'.u.count('ej-m') end
279  
-  expect 0 do 'y'.u.count('a\\-z') end
280  
-  expect 5 do 'abcあいう'.u.count('^a') end
281  
-  expect 5 do 'abcあいう'.u.count('^あ') end
282  
-  expect 2 do 'abcあいう'.u.count('a-z', '^a') end
283  
-  expect ArgumentError.new('wrong number of arguments (0 for at least 1)') do 'föö'.u.count end
  514
+  # TODO Add tests for Unicode whitespace characters
  515
+  expect 'あ'.u do 'あ'.u.lstrip end
  516
+  expect 'あ'.u do '     あ'.u.lstrip end
  517
+  expect 'あ     '.u do 'あ     '.u.lstrip end
  518
+  expect result.tainted? do 'あ'.u.taint.lstrip end
  519
+  expect result.untrusted? do 'あ'.u.untrust.lstrip end
284 520
 
285  
-  expect true do ''.u.defined? end
286  
-  expect true do 'a'.u.defined? end
287  
-  expect true do 'ab'.u.defined? end
288  
-  expect false do [0x0588].pack('U').u.defined? end
289  
-  # TODO: This raises an error, as we’re using u_aref_char_validated_n for
290  
-  # these functions.  Perhaps use u_aref_char_n and don’t raise errors on
291  
-  # invalid input.
292  
-  # expect false do [0xD800].pack('U').u.defined? end
  521
+  expect ArgumentError.new('string is empty') do ''.u.ord end
  522
+  expect 0x00e4 do 'ä'.u.ord end
  523
+  expect 0x00e4 do 'äbc'.u.ord end
293 524
 
294  
-  expect 'hë wrd'.u do 'hëllö wörld'.u.delete('lö') end
295  
-  expect 'hëö wörd'.u do 'hëllö wörld'.u.delete('l', 'lö') end
296  
-  expect 'hëll wrld'.u do 'hëllö wörld'.u.delete('lö', 'ö') end
297  
-  expect 'hëll wrld'.u do 'hëllö wörld'.u.delete('aëiöu', '^ë') end
298  
-  expect 'hö wörd'.u do 'hëllö wörld'.u.delete('ëj-m') end
299  
-  expect 'a'.u do 'aā'.u.delete('ā') end
300  
-  expect 'a'.u do 'abcあいう'.u.delete('^a') end
301  
-  expect 'bcあいう'.u do 'abcあいう'.u.delete('a') end
302  
-  expect 'あ'.u do 'abcあいう'.u.delete('^あ') end
303  
-  expect ArgumentError.new('wrong number of arguments (0 for at least 1)') do 'föö'.u.delete end
304  
-  expect result.tainted? do 'a'.u.taint.delete('a') end
305  
-  expect result.untrusted? do 'a'.u.untrust.delete('a') end
  525
+  # TODO Add tests for Unicode whitespace characters
  526
+  expect 'あ'.u do 'あ'.u.rstrip end
  527
+  expect '     あ'.u do '     あ'.u.rstrip end
  528
+  expect 'あ'.u do 'あ     '.u.rstrip end
  529
+  expect result.tainted? do 'あ'.u.taint.rstrip end
  530
+  expect result.untrusted? do 'あ'.u.untrust.rstrip end
306 531
 
307  
-  expect true do ''.u.digit? end
308  
-  expect true do '0'.u.digit? end
309  
-  expect true do '01'.u.digit? end
310  
-  expect false do '0a'.u.digit? end
  532
+  # TODO Add tests for Unicode whitespace characters
  533
+  expect 'あ'.u do 'あ'.u.strip end
  534
+  expect 'あ'.u do '     あ'.u.strip end
  535
+  expect 'あ'.u do 'あ     '.u.strip end
  536
+  expect 'あ'.u do '     あ     '.u.strip end
  537
+  expect result.tainted? do 'あ'.u.taint.strip end
  538
+  expect result.untrusted? do 'あ'.u.untrust.strip end
311 539
 
312 540
   expect 'hëllö'.u do 'hëlLÖ'.u.downcase end
313 541
   expect 'hëllö'.u do 'hëllö'.u.downcase end
314 542
   expect 'hëllö'.u do 'HËLLÖ'.u.downcase end
315 543
   expect "abc\0dëf".u do "ABC\0DËF".u.downcase end
316  
-
317 544
   expect 'σ'.u do 'Σ'.u.downcase end
318 545
   expect 'ας'.u do 'ΑΣ'.u.downcase end
319 546
   expect 'ασβ'.u do 'ΑΣΒ'.u.downcase end
320 547
   expect 'ας '.u do 'ΑΣ '.u.downcase end
321 548
   expect 'ας’'.u do 'ΑΣ’'.u.downcase end
322 549
   expect '’σ'.u do '’Σ'.u.downcase end
323  
-
324 550
   expect 'i'.u do 'I'.u.downcase('lt') end
325  
-
326 551
   expect "i\xcc\x87\xcc\x80\xcc\x87".u do "I\xcc\x80\xcc\x87".u.downcase('lt') end
327 552
   expect "i\xcc\x87\xcc\x87".u do "I\xcc\x87".u.downcase('lt') end
328  
-
329 553
   expect "i\xcc\x87\xcc\x80".u do "I\xcc\x80".u.downcase('lt') end
330 554
   expect "j\xcc\x87\xcc\x80".u do "J\xcc\x80".u.downcase('lt') end
331 555
   expect "į\xcc\x87\xcc\x80".u do "Į\xcc\x80".u.downcase('lt') end
332 556
   expect "i\xcc\x87\xcc\x80".u do 'Ì'.u.downcase('lt') end
333 557
   expect "i\xcc\x87\xcc\x81".u do 'Í'.u.downcase('lt') end
334 558
   expect "i\xcc\x87\xcc\x83".u do 'Ĩ'.u.downcase('lt') end
335  
-
336 559
   expect 'i'.u do 'İ'.u.downcase('tr') end
337 560
   expect 'i'.u do 'İ'.u.downcase('az') end
338  
-
339 561
   expect 'i'.u do 'İ'.u.downcase('tr') end
340 562
   expect 'i'.u do 'İ'.u.downcase('az') end
341  
-
342 563
   expect 'ı'.u do 'I'.u.downcase('tr') end
343 564
   expect 'ı'.u do 'I'.u.downcase('az') end
344  
-
345 565
   expect result.tainted? do 'A'.u.taint.downcase end
346 566
   expect result.untrusted? do 'A'.u.untrust.downcase end
347 567
 
348  
-  expect 'Ab Iς Ssσ/Ffi'.u do 'aB iς ßσ/ffi'.u.titlecase end
  568
+  expect "abc\0ss".u do "abc\0ß".u.foldcase end
  569
+  expect result.tainted? do 'a'.u.taint.foldcase end
  570
+  expect result.untrusted? do 'a'.u.untrust.foldcase end
349 571
 
  572
+  expect 'Ab Iς Ssσ/Ffi'.u do 'aB iς ßσ/ffi'.u.titlecase end
350 573
   expect 'Ijssel Igloo Ijssel'.u do 'ijssEl iglOo IJSSEL'.u.titlecase end
351 574
   expect 'IJssel Igloo IJssel'.u do 'ijssEl iglOo IJSSEL'.u.titlecase('nl') end
352 575
 
353  
-  expect '"\xC3bc\u{e4}bc".u'.u do "\xC3bcäbc".u.dump end
354  
-  expect result.tainted? do ''.u.taint.dump end
355  
-  expect result.untrusted? do ''.u.untrust.dump end
356  
-
357  
-  expect [0x61, 0x62, 0x63, 0x00, 0x64, 0xc3, 0xab, 0x66] do
358  
-    "abc\0dëf".u.bytes.entries
359  
-  end
360  
-
361  
-  expect ['h'.u, 'ë'.u, 'l'.u, 'l'.u, 'ö'.u] do
362  
-    'hëllö'.u.chars.entries
363  
-  end
364  
-
365  
-  expect result.tainted? do 'a'.u.taint.chars.first end
366  
-  expect result.untrusted? do 'a'.u.untrust.chars.first end
367  
-
368  
-  expect [0x0068, 0x00eb, 0x006c, 0x006c, 0x00f6] do
369  
-    'hëllö'.u.codepoints.entries
370  
-  end
  576
+  expect 'HËLLÖ'.u do 'hëlLÖ'.u.upcase end
  577
+  expect 'HËLLÖ'.u do 'hëllö'.u.upcase end
  578
+  expect 'HËLLÖ'.u do 'HËLLÖ'.u.upcase end
  579
+  expect "ABC\0DËF".u do "abc\0dëF".u.upcase end
  580
+  expect "I\xcc\x87".u do "i\xcc\x87".u.upcase end
  581
+  expect 'I'.u do "i\xcc\x87".u.upcase('lt') end
  582
+  expect "K\xcc\x87".u do "k\xcc\x87".u.upcase('lt') end
  583
+  expect "A\xcc\x81Ι".u do "a\xcd\x85\xcc\x81".u.upcase end
  584
+  expect 'I'.u do 'i'.u.upcase end
  585
+  expect 'İ'.u do 'i'.u.upcase('tr') end
  586
+  expect result.tainted? do 'a'.u.taint.upcase end
  587
+  expect result.untrusted? do 'a'.u.untrust.upcase end
371 588
 
372  
-  expect ["hello\n".u, 'world'.u] do
373  
-    saved_rs = $/
374  
-    begin
375  
-      $/ = "\n"
376  
-      "hello\nworld".u.lines.entries
377  
-    ensure
378  
-      $/ = saved_rs
379  
-    end
380  
-  end
  589
+  expect ''.u do ''.u.mirror end
  590
+  expect ')'.u do '('.u.mirror end
  591
+  expect ')('.u do '()'.u.mirror end
  592
+  expect result.tainted? do ''.u.taint.mirror end
  593
+  expect result.untrusted? do ''.u.untrust.mirror end
381 594
 
382  
-  expect ["hello\n\n\n".u, 'world'.u] do
383  
-      "hello\n\n\nworld".u.lines('').entries
384  
-  end
  595
+  expect TypeError.new('not a symbol: 1') do ''.u.normalize(1) end
  596
+  expect ArgumentError.new('unknown normalization mode: :ufc') do ''.u.normalize(:ufc) end
  597
+  expect 'Ḋ'.u do "D\xcc\x87".u.normalize(:nfc) end
  598
+  expect result.tainted? do ''.u.taint.normalize end
  599
+  expect result.untrusted? do ''.u.untrust.normalize end
385 600
 
386  
-  expect ['hello!'.u, 'world'.u] do
387  
-    saved_rs = $/
388  
-    begin
389  
-      $/ = '!'
390  
-      'hello!world'.u.lines.entries
391  
-    ensure
392  
-      $/ = saved_rs
393  
-    end
394  
-  end
  601
+  expect 'ateb'.u do 'beta'.u.reverse end
  602
+  expect 'madamImadam'.u do 'madamImadam'.u.reverse end
  603
+  expect "alpha\0beta".u do "ateb\0ahpla".u.reverse end
  604
+  expect result.tainted? do 'a'.u.taint.reverse end
  605
+  expect result.untrusted? do 'a'.u.untrust.reverse end
395 606
 
396  
-  expect ["hello\nworld".u] do
397  
-    saved_rs = $/
398  
-    begin
399  
-      $/ = nil
400  
-      "hello\nworld".u.lines.entries
401  
-    ensure
402  
-      $/ = saved_rs
403  
-    end
404  
-  end
  607
+  expect 'hëllö'.u do 'hëllö'.u.center(4) end
  608
+  expect '   hëllö   '.u do 'hëllö'.u.center(11) end
  609
+  expect 'ababaababa'.u do ''.u.center(10, 'ab') end
  610
+  expect 'ababaababab'.u do ''.u.center(11, 'ab') end
  611
+  expect 'あ3あ'.u do '3'.u.center(5, 'あ') end
  612
+  expect ArgumentError.new('zero-width padding') do '3'.u.center(2, '') end
  613
+  expect 'あ3あ'.u do '3'.u.center(5, 'あ ') end
  614
+  expect 'あ3あ '.u do '3'.u.center(6, 'あ ') end
  615
+  expect 'あ 3あ '.u do '3'.u.center(7, 'あ ') end
  616
+  expect ArgumentError.new('padding is too wide to complete rounding (2 > 1)') do '3'.u.center(4, 'あ') end
  617
+  # TODO Adjust this to LONG_MAX in Ruby
  618
+  # expect ArgumentError do ''.u.center(9223372036854775807) end
  619
+  expect result.tainted? do 'a'.u.taint.center(1) end
  620
+  expect result.untrusted? do 'a'.u.untrust.center(1) end
  621
+  expect result.tainted? do 'a'.u.taint.center(3) end
  622
+  expect result.untrusted? do 'a'.u.untrust.center(3) end
  623
+  expect result.not.tainted? do 'a'.u.center(1, ' '.taint) end
  624
+  expect result.not.untrusted? do 'a'.u.center(1, ' '.untrust) end
  625
+  expect result.tainted? do 'a'.u.taint.center(3, ' '.taint) end
  626
+  expect result.untrusted? do 'a'.u.untrust.center(3, ' '.untrust) end
405 627
 
406  
-  expect ['hëll hëllö'.u, ' world'.u] do
407  
-    'hëll hëllö world'.u.lines('llö').entries
408  
-  end
  628
+  expect 5 do 'hëllö wörld'.u.count('lö') end
  629
+  expect 3 do 'hëllö wörld'.u.count('l', 'lö') end
  630
+  expect 2 do 'hëllö wörld'.u.count('lö', 'ö') end
  631
+  expect 4 do 'hëllö wörld'.u.count('hëllö', '^l') end
  632
+  expect 3 do 'hëllö wörld'.u.count('ej-m') end
  633
+  expect 0 do 'y'.u.count('a\\-z') end
  634
+  expect 5 do 'abcあいう'.u.count('^a') end
  635
+  expect 5 do 'abcあいう'.u.count('^あ') end
  636
+  expect 2 do 'abcあいう'.u.count('a-z', '^a') end
  637
+  expect ArgumentError.new('wrong number of arguments (0 for at least 1)') do 'föö'.u.count end
409 638
 
410  
-  expect ["hello\0".u, 'world'.u] do
411  
-    "hello\0world".u.lines("\0").entries
412  
-  end
  639
+  expect 'hë wrd'.u do 'hëllö wörld'.u.delete('lö') end
  640
+  expect 'hëö wörd'.u do 'hëllö wörld'.u.delete('l', 'lö') end
  641
+  expect 'hëll wrld'.u do 'hëllö wörld'.u.delete('lö', 'ö') end
  642
+  expect 'hëll wrld'.u do 'hëllö wörld'.u.delete('aëiöu', '^ë') end
  643
+  expect 'hö wörd'.u do 'hëllö wörld'.u.delete('ëj-m') end
  644
+  expect 'a'.u do 'aā'.u.delete('ā') end
  645
+  expect 'a'.u do 'abcあいう'.u.delete('^a') end
  646
+  expect 'bcあいう'.u do 'abcあいう'.u.delete('a') end
  647
+  expect 'あ'.u do 'abcあいう'.u.delete('^あ') end
  648
+  expect ArgumentError.new('wrong number of arguments (0 for at least 1)') do 'föö'.u.delete end
  649
+  expect result.tainted? do 'a'.u.taint.delete('a') end
  650
+  expect result.untrusted? do 'a'.u.untrust.delete('a') end
413 651
 
414  
-  expect result.tainted? do 'a'.u.taint.lines.first end
415  
-  expect result.untrusted? do 'a'.u.untrust.lines.first end
  652
+  expect 'äbc'.u do 'äääbbbbccc'.u.squeeze end
  653
+  expect 'ää bb cc'.u do 'ää   bb   cc'.u.squeeze(' ') end
  654
+  expect 'BxTÿWz'.u do 'BxTÿÿÿWzzz'.u.squeeze('a-zä-ÿ') end
  655
+  expect result.tainted? do 'abc'.u.taint.squeeze end
  656
+  expect result.untrusted? do 'abc'.u.untrust.squeeze end
  657
+  expect result.not.tainted? do 'abc'.u.squeeze('b'.taint) end
  658
+  expect result.not.untrusted? do 'abc'.u.squeeze('b'.untrust) end
416 659
 
417  
-  expect result.to.be.empty? do ''.u end
418  
-  expect result.not.to.be.empty? do 'not'.u end
  660
+  expect 'hïppö' do 'hëllö'.u.tr('ël', 'ïp') end
  661
+  expect '*ë**ö' do 'hëllö'.u.tr('^aëiöu', '*') end
  662
+  expect 'hal' do 'ibm'.u.tr('b-z', 'a-z') end
  663
+  expect 'hal' do 'hal'.u.tr('a-z', 'a-z') end
  664
+  expect true do a = 'hal'.u; a.tr('a-z', 'a-z').object_id == a.object_id end
  665
+  expect result.tainted? do 'abc'.u.taint.tr('a', 'b') end
  666
+  expect result.untrusted? do 'abc'.u.untrust.tr('a', 'b') end
  667
+  expect result.not.tainted? do 'abc'.u.tr('a'.taint, 'b') end
  668
+  expect result.not.untrusted? do 'abc'.u.tr('a'.untrust, 'b') end
  669
+  expect result.not.tainted? do 'abc'.u.tr('a', 'b'.taint) end
  670
+  expect result.not.untrusted? do 'abc'.u.tr('a', 'b'.untrust) end
419 671
 
420  
-  expect result.to.end_with?('c') do 'abc'.u end
421  
-  expect result.not.to.end_with?('d') do 'abc'.u end
422  
-  expect result.to.end_with?('ä') do 'cbä'.u end
423  
-  expect result.not.to.end_with?('äb') do 'cbä'.u end
424  
-  expect result.to.end_with?('a', 'ä') do 'cbä'.u end
425  
-  expect result.not.to.end_with? do 'cbä'.u end
  672
+  expect ['hë'.u, 'l'.u, 'lö'.u] do 'hëllö'.u.partition(/l/u) end
  673
+  expect ['hë'.u, 'l'.u, 'lö'.u] do 'hëllö'.u.partition('l'.u) end
  674
+  expect ['hë'.u, 'l'.u, 'lö'.u] do 'hëllö'.u.partition('l') end
  675
+  expect TypeError do 'hëllö'.u.partition(0) end
  676
+  expect ['föö'.u, '-'.u, 'bär'.u] do 'föö-bär'.u.partition(stub(:to_str => '-')) end
  677
+  expect [true, true, true] do 'abc'.u.taint.partition(/b/).map(&:tainted?) end
  678
+  expect [true, true, true] do 'abc'.u.untrust.partition(/b/).map(&:untrusted?) end
  679
+  expect [false, true, false] do 'abc'.u.partition(/b/.taint).map(&:tainted?) end
  680
+  expect [false, true, false] do 'abc'.u.partition(/b/.untrust).map(&:untrusted?) end
  681
+  expect [true, true, true] do 'abc'.u.taint.partition(/b/.taint).map(&:tainted?) end
  682
+  expect [true, true, true] do 'abc'.u.untrust.partition(/b/.untrust).map(&:untrusted?) end
  683
+  expect [true, false, true] do 'abc'.u.taint.partition('b').map(&:tainted?) end
  684
+  expect [true, false, true] do 'abc'.u.untrust.partition('b').map(&:untrusted?) end
  685
+  expect [false, true, false] do 'abc'.u.partition('b'.taint).map(&:tainted?) end
  686
+  expect [false, true, false] do 'abc'.u.partition('b'.untrust).map(&:untrusted?) end
  687
+  expect [true, true, true] do 'abc'.u.taint.partition('b'.taint).map(&:tainted?) end
  688
+  expect [true, true, true] do 'abc'.u.untrust.partition('b'.untrust).map(&:untrusted?) end
426 689
 
427  
-  expect "abc\0ss".u do "abc\0ß".u.foldcase end
428  
-  expect result.tainted? do 'a'.u.taint.foldcase end
429  
-  expect result.untrusted? do 'a'.u.untrust.foldcase end
  690
+  expect ['hël'.u, 'l'.u, 'ö'.u] do 'hëllö'.u.rpartition(/l/u) end
  691
+  expect ['hël'.u, 'l'.u, 'ö'.u] do 'hëllö'.u.rpartition('l'.u) end
  692
+  expect ['hël'.u, 'l'.u, 'ö'.u] do 'hëllö'.u.rpartition('l') end
  693
+  expect TypeError do 'hëllö'.u.rpartition(0) end
  694
+  expect ['föö'.u, '-'.u, 'bär'.u] do 'föö-bär'.u.rpartition(stub(:to_str => '-')) end
  695
+  expect [true, true, true] do 'abc'.u.taint.rpartition(/b/).map(&:tainted?) end
  696
+  expect [true, true, true] do 'abc'.u.untrust.rpartition(/b/).map(&:untrusted?) end
  697
+  expect [false, true, false] do 'abc'.u.rpartition(/b/.taint).map(&:tainted?) end
  698
+  expect [false, true, false] do 'abc'.u.rpartition(/b/.untrust).map(&:untrusted?) end
  699
+  expect [true, true, true] do 'abc'.u.taint.rpartition(/b/.taint).map(&:tainted?) end
  700
+  expect [true, true, true] do 'abc'.u.untrust.rpartition(/b/.untrust).map(&:untrusted?) end
  701
+  expect [true, false, true] do 'abc'.u.taint.rpartition('b').map(&:tainted?) end
  702
+  expect [true, false, true] do 'abc'.u.untrust.rpartition('b').map(&:untrusted?) end
  703
+  expect [false, true, false] do 'abc'.u.rpartition('b'.taint).map(&:tainted?) end
  704
+  expect [false, true, false] do 'abc'.u.rpartition('b'.untrust).map(&:untrusted?) end
  705
+  expect [true, true, true] do 'abc'.u.taint.rpartition('b'.taint).map(&:tainted?) end
  706
+  expect [true, true, true] do 'abc'.u.untrust.rpartition('b'.untrust).map(&:untrusted?) end
430 707
 
431  
-  expect true do 'ss'.u.folded? end
432  
-  expect false do 'ß'.u.folded? end
433  
-  expect true do 'abc\0ß'.u.foldcase.folded? end
  708
+  expect ['crüel'.u, 'wörld'.u] do 'crüel wörld'.u.scan(/[[:word:]]+/u) end
  709
+  expect ['crü'.u, 'el '.u, 'wör'.u] do 'crüel wörld'.u.scan(/.../u) end
  710
+  expect [['crü'.u], ['el '.u], ['wör'.u]] do 'crüel wörld'.u.scan(/(...)/u) end
  711
+  expect ['crüel'.u, 'wörld'.u] do 'crüel wörld'.u.to_enum(:scan, /[[:word:]]+/u).to_a end
  712
+  expect ['crü'.u, 'el '.u, 'wör'.u] do 'crüel wörld'.u.to_enum(:scan, /.../u).to_a end
  713
+  expect [['crü'.u], ['el '.u], ['wör'.u]] do 'crüel wörld'.u.to_enum(:scan, /(...)/u).to_a end
  714
+  expect [''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u, ''.u] do 'crüel wörld'.u.scan(//u) end
  715
+  expect [true, true] do 'crüel wörld'.u.taint.scan(/[[:word:]]+/u).map(&:tainted?) end
  716
+  expect [true, true] do 'crüel wörld'.u.untrust.scan(/[[:word:]]+/u).map(&:untrusted?) end
  717
+  expect [true, true] do 'crüel wörld'.u.scan(/[[:word:]]+/u.taint).map(&:tainted?) end
  718
+  expect [true, true] do 'crüel wörld'.u.scan(/[[:word:]]+/u.untrust).map(&:untrusted?) end
  719
+  expect [true] do 'crüel wörld'.u.taint.scan(' ').map(&:tainted?) end
  720
+  expect [true] do 'crüel wörld'.u.untrust.scan(' ').map(&:untrusted?) end
  721
+  expect [false] do 'crüel wörld'.u.scan(' '.taint).map(&:tainted?) end
  722
+  expect [false] do 'crüel wörld'.u.scan(' '.untrust).map(&:untrusted?) end
  723
+  expect [] do ''.u.split(''.u, 1) end
  724
+  expect ['abc'.u] do 'abc'.u.split(''.u, 1) end
  725
+  expect [true, true] do 'abc'.u.taint.split(/b/).map(&:tainted?) end
  726
+  expect [true, true] do 'abc'.u.untrust.split(/b/).map(&:untrusted?) end
  727
+  expect [false, false] do 'abc'.u.split(/b/.taint).map(&:tainted?) end
  728
+  expect [false, false] do 'abc'.u.split(/b/.untrust).map(&:untrusted?) end
  729
+  expect [true, true] do 'abc'.u.taint.split('b').map(&:tainted?) end
  730
+  expect [true, true] do 'abc'.u.untrust.split('b').map(&:untrusted?) end
  731
+  expect [false, false] do 'abc'.u.split('b'.taint).map(&:tainted?) end
  732
+  expect [false, false] do 'abc'.u.split('b'.untrust).map(&:untrusted?) end
  733
+  expect [' ä '.u, ' b '.u, ' c '.u] do ' ä | b | c '.u.split('|'.u) end
  734
+  expect ['ä|b|c'.u] do 'ä|b|c'.u.split('|'.u, 1) end
  735
+  expect ['ä'.u, 'b|c'.u] do 'ä|b|c'.u.split('|'.u, 2) end
  736
+  expect ['ä'.u, 'b'.u, 'c'.u] do 'ä|b|c'.u.split('|'.u, 3) end
  737
+  expect ['ä'.u, 'b'.u, 'c'.u, ''.u] do 'ä|b|c|'.u.split('|'.u, -1) end
  738
+  expect ['ä'.u, 'b'.u, 'c'.u, ''.u, ''.u] do 'ä|b|c||'.u.split('|'.u, -1) end
  739
+  expect ['ä'.u, ''.u, 'b'.u, 'c'.u] do 'ä||b|c|'.u.split('|'.u) end
  740
+  expect ['ä'.u, ''.u, 'b'.u, 'c'.u, ''.u] do 'ä||b|c|'.u.split('|'.u, -1) end
  741
+  expect [] do with_global(:$;, nil){ '  '.u.split } end
  742
+  expect [''.u] do with_global(:$;, nil){ '  '.u.split(nil, -1) } end
  743
+  expect ['ä'.u, 'b c'.u] do with_global(:$;, nil){ 'ä b c'.u.split(nil, 2) } end
  744
+  expect ['ä'.u, 'b'.u, 'c'.u] do with_global(:$;, nil){ " ä  b\t c ".u.split } end
  745
+  expect ['ä'.u, "b\t c ".u] do with_global(:$;, nil){ " ä  b\t c ".u.split(nil, 2) } end
  746
+  expect ['ä'.u, 'b'.u, 'c'.u] do with_global(:$;, nil){ " ä  b\t c".split } end
  747
+  expect ['ä'.u, 'b'.u, 'c'.u] do with_global(:$;, nil){ " ä  b\t c".u.split(' ') } end
  748
+  expect [] do ''.split(//u, 1) end
  749
+  expect ['ä'.u, 'b'.u, 'c'.u] do 'äXXbXXcXX'.u.split(/X./u) end
  750
+  expect ['ä'.u, 'b'.u, 'c'.u] do 'äbc'.u.split(//u) end
  751
+  expect ['b'.u, 'c'.u] do 'bäc'.u.split(/ä?/u) end
  752
+
  753
+  expect 'bbc'.u do 'abc'.u.gsub('a', 'b') end
  754
+  expect 'h*ll*'.u do 'hello'.u.gsub(/[aeiou]/u, '*'.u) end
  755
+  expect 'h*ll*'.u do 'hëllö'.u.gsub(/[äëïöü]/u, '*'.u) end
  756
+  expect 'h<ë>ll<ö>'.u do 'hëllö'.u.gsub(/([äëïöü])/u, '<\\1>'.u) end
  757
+  expect 'h<ë>ll<ö>'.u do 'hëllö'.u.gsub(/([ëö])/u, 'ë'.u => '<ë>'.u, 'ö'.u => '<ö>'.u) end
  758
+  expect 'h ë l l ö '.u do 'hëllö'.u.gsub(/./u){ |s| s[0].to_s + ' ' } end
  759
+  expect 'HËLL-ö'.u do 'hëllö'.u.gsub(/(hëll)(.)/u){ |s| $1.u.upcase + '-'.u + $2.u } end
  760
+  expect ArgumentError do 'hëllö'.gsub end
  761
+  expect result.tainted? do 'a'.u.taint.gsub(/a/, 'b') end
  762
+  expect result.untrusted? do 'a'.u.untrust.gsub(/a/, 'b') end
  763
+  expect result.not.tainted? do 'a'.u.gsub(/a/.taint, 'b') end
  764
+  expect result.not.untrusted? do 'a'.u.gsub(/a/.untrust, 'b') end
  765
+  expect result.tainted? do 'a'.u.gsub(/a/, 'b'.taint) end
  766
+  expect result.untrusted? do 'a'.u.gsub(/a/, 'b'.untrust) end
  767
+  expect result.tainted? do 'a'.u.gsub(/a/, {'a'.u => 'b'}.taint) end
  768
+  expect result.not.untrusted? do 'a'.u.gsub(/a/, {'a'.u => 'b'}.untrust) end
  769
+  expect result.tainted? do 'a'.u.gsub(/a/, {'a'.u => 'b'.taint}) end
  770
+  expect result.untrusted? do 'a'.u.gsub(/a/, {'a'.u => 'b'.untrust}) end
  771
+  expect result.tainted? do 'a'.u.gsub(/a/, Hash.new{ 'b'.taint }) end
  772
+  expect result.untrusted? do 'a'.u.gsub(/a/, Hash.new{ 'b'.untrust }) end
  773
+  expect result.tainted? do 'a'.u.gsub(/a/){ 'b'.taint } end
  774
+  expect result.untrusted? do 'a'.u.gsub(/a/){ 'b'.untrust } end
  775
+
  776
+  expect 'bbc'.u do 'abc'.u.sub('a', 'b') end
  777
+  expect 'h*llo'.u do 'hello'.u.sub(/[aeiou]/u, '*'.u) end
  778
+  expect 'h*llö'.u do 'hëllö'.u.sub(/[äëïöü]/u, '*'.u) end
  779
+  expect 'h<ë>llö'.u do 'hëllö'.u.sub(/([äëïöü])/u, '<\\1>'.u) end
  780
+  expect 'h<ë>llö'.u do 'hëllö'.u.sub(/([ëö])/u, 'ë'.u => '<ë>'.u, 'ö'.u => '<ö>'.u) end
  781
+  expect 'h ëllö'.u do 'hëllö'.u.sub(/./u){ |s| s[0].to_s + ' ' } end
  782
+  expect 'HËLL-ö'.u do 'hëllö'.u.sub(/(hëll)(.)/u){ |s| $1.u.upcase + '-'.u + $2.u } end
  783
+  expect ArgumentError do 'hëllö'.sub end
  784
+  expect result.tainted? do 'a'.u.taint.sub(/a/, 'b') end
  785
+  expect result.untrusted? do 'a'.u.untrust.sub(/a/, 'b') end
  786
+  expect result.not.tainted? do 'a'.u.sub(/a/.taint, 'b') end
  787
+  expect result.not.untrusted? do 'a'.u.sub(/a/.untrust, 'b') end
  788
+  expect result.tainted? do 'a'.u.sub(/a/, 'b'.taint) end
  789
+  expect result.untrusted? do 'a'.u.sub(/a/, 'b'.untrust) end
  790
+  expect result.tainted? do 'a'.u.sub(/a/, {'a'.u => 'b'}.taint) end
  791
+  expect result.untrusted? do 'a'.u.sub(/a/, {'a'.u => 'b'}.untrust) end
  792
+  expect result.tainted? do 'a'.u.sub(/a/, {'a'.u => 'b'.taint}) end
  793
+  expect result.untrusted? do 'a'.u.sub(/a/, {'a'.u => 'b'.untrust}) end
  794
+  expect result.tainted? do 'a'.u.sub(/a/, Hash.new{ 'b'.taint }) end
  795
+  expect result.untrusted? do 'a'.u.sub(/a/, Hash.new{ 'b'.untrust }) end
  796
+  expect result.tainted? do 'a'.u.sub(/a/){ 'b'.taint } end
  797
+  expect result.untrusted? do 'a'.u.sub(/a/){ 'b'.untrust } end
  798
+
  799
+  expect 'hëll'.u do 'hëll'.u + ''.u end
  800
+  expect 'ö'.u do ''.u + 'ö'.u end
  801
+  expect 'hëllö'.u do 'hëll'.u + 'ö'.u end
  802
+  expect result.tainted? do ''.u.taint + ''.u end
  803
+  expect result.tainted? do ''.u + ''.u.taint end
  804
+  expect result.not.untrusted? do ''.u.untrust + ''.u end
  805
+  expect result.not.untrusted? do ''.u + ''.u.untrust end
  806
+
  807
+  expect ArgumentError do '*'.u * -1 end
  808
+  expect ''.u do ''.u * 10 end
  809
+  expect '**********'.u do '*'.u * 10 end
  810
+  # TODO Test LONG_MAX.
  811
+  expect result.tainted? do ''.u.taint * 10 end
  812
+  expect result.untrusted? do ''.u.untrust * 10 end
434 813
 
435 814
   expect 'äbc'.u do 'äbc'.u % [] end
436 815
 
@@ -478,7 +857,7 @@
478 857
   expect ArgumentError.new('cannot use positional argument numbers after named arguments') do '%<a>c%c'.u % { :a => 0x00e4 } end
479 858
   expect ArgumentError.new('wrong number of arguments (0 for at least 1)') do '%c'.u % [] end
480 859
 
481  
-  # TODO: Add flag checks?
  860
+  # TODO Add flag checks?
482 861
   expect 'äbc'.u do '%sc'.u % ['äb'.u] end
483 862
   expect 'äc'.u do '%.1sc'.u % ['äb'.u] end
484 863
   expect ' äbc'.u do '%3sc'.u % ['äb'.u] end
@@ -493,7 +872,7 @@
493 872
   expect 'あbc'.u do '%.4s'.u % ['あbc'.u] end
494 873
   expect ' あbc'.u do '%5s'.u % ['あbc'.u] end
495 874
 
496  
-  # TODO: Add flag checks?
  875
+  # TODO Add flag checks?
497 876
   expect '"äbc".u'.u do '%p'.u % ['äbc'.u] end
498 877
 
499 878
   expect '123'.u do '%d'.u % 123 end
@@ -523,15 +902,7 @@
523 902
   expect '+123  '.u do '%-+6d'.u % 123 end
524 903
   expect '-123  '.u do '%-6d'.u % -123 end
525 904
 
526  
-  expect '123   '.u do
527  
-    saved_verbose = $VERBOSE
528  
-    $VERBOSE = nil
529  
-    begin
530  
-      '%-06d'.u % 123
531  
-    ensure
532  
-      $VERBOSE = saved_verbose
533  
-    end
534  
-  end
  905
+  expect '123   '.u do with_verbose(nil){ '%-06d'.u % 123 } end
535 906
 
536 907
   expect '000123'.u do '%.6d'.u % 123 end
537 908
   expect ' 000123'.u do '% .6d'.u % 123 end
@@ -549,7 +920,7 @@
549 920
   expect '+000123  '.u do '%-+9.6d'.u % 123 end
550 921
   expect '-000123  '.u do '%-9.6d'.u % -123 end
551 922
 
552  
-  # TODO: Need a lot more tests for Bignum code-paths.
  923
+  # TODO Need a lot more tests for Bignum code-paths.
553 924
   expect Bignum do 12345678901234567890 end
554 925
   expect '12345678901234567890'.u do '%d'.u % 12345678901234567890 end
555 926
 
@@ -609,7 +980,7 @@
609 980
   expect '   000' do with_verbose(nil){ '%06.3o'.u % 0 } end
610 981
   expect '   000' do with_verbose(nil){ '%#06.3o'.u % 0 } end
611 982
 
612  
-  # TODO: Need a lot more Bignum tests
  983
+  # TODO Need a lot more Bignum tests.
613 984
   expect Bignum do 01255245230635307605322 end
614 985
   expect '1255245230635307605322'.u do '%o'.u % 01255245230635307605322 end
615 986
 
@@ -712,7 +1083,6 @@
712 1083
   expect '  +101'.u do '%+6b'.u % 0b101 end
713 1084
   expect '  -101'.u do '%+6b'.u % -0b101 end
714 1085
 
715  
-
716 1086
   expect ' 0b101'.u do '%#6b'.u % 0b101 end
717 1087
   expect ' 0b101'.u do '%# 6b'.u % 0b101 end
718 1088
   expect '+0b101'.u do '%#+6b'.u % 0b101 end
@@ -770,612 +1140,131 @@