|
1 | 1 | use nqpmo;
|
2 | 2 |
|
3 |
| -plan(27); |
| 3 | +plan(22); |
4 | 4 |
|
5 | 5 |
|
6 | 6 | my sub create_buf($type) {
|
@@ -56,38 +56,16 @@ my $hello2 := $buf8.new;
|
56 | 56 | nqp::encode('Hello World', 'utf8', $hello2);
|
57 | 57 | is(buf_dump($hello2), "72,101,108,108,111,32,87,111,114,108,100", "the buf passed to nqp::encode is actually changed");
|
58 | 58 |
|
59 |
| -# encode/decode config tests |
60 |
| -my $replaced_ascii := nqp::encoderepconf('åfooåbar', 'ascii', 'XXX', $buf8.new, 0); |
| 59 | +my $replaced_ascii := nqp::encoderep('åfooåbar', 'ascii', 'XXX', $buf8.new); |
61 | 60 | is(nqp::decode($replaced_ascii, "utf8"), 'XXXfooXXXbar', 'nqp::encoderep works with ascii');
|
62 | 61 |
|
63 | 62 | my $replaced_latin1 := nqp::encoderep('☃foo☃barå', 'iso-8859-1', 'XXX', $buf8.new);
|
64 | 63 | is(nqp::decode($replaced_latin1, 'iso-8859-1'), 'XXXfooXXXbarå', 'nqp::encoderep works with latin1');
|
65 | 64 |
|
66 | 65 | my $replaced_windows1252 := nqp::encoderep('☃foo☃barå', 'windows-1252', 'XXX', $buf8.new);
|
67 |
| - |
68 |
| -my $replaced_w := nqp::encoderepconf("\c[129]åfooåbar→", 'windows-1252', 'XXX', $buf8.new, 1); |
69 |
| -is(nqp::decodeconf($replaced_w, "windows-1252", 1), "\c[129]åfooåbarXXX", |
70 |
| - 'nqp::encoderepconf(.., 1) only replaces things not fiting in one byte'); |
71 |
| -my $replaced_w2 := nqp::encoderepconf("\c[129]åfooåbar", 'windows-1252', 'XXX', $buf8.new, 0); |
72 |
| -is(nqp::decode($replaced_w2, "windows-1252"), "XXXåfooåbar", |
73 |
| - 'nqp::encoderepconf(…, 0) replaces anything not officially mapped.'); |
74 |
| -# Encode chr 129 using unstrict mode (invalid codepoint otherwise) |
75 |
| -my $special_windows1252 := nqp::encodeconf(nqp::chr(129), 'windows-1252', $buf8.new, 1); |
76 |
| -# Test that it can be decoded unstrict |
77 |
| -is(nqp::decodeconf($special_windows1252, 'windows-1252', 1), "\c[129]", |
78 |
| - 'nqp::encodeconf works with windows-1252 and non-strict. decodeconf works non-strict'); |
79 |
| -# Test we can decode invalid codepoint and it is replaced instead on strict mode |
80 |
| -is(nqp::decoderepconf($special_windows1252, 'windows-1252', 'X', 0), "X", |
81 |
| - "nqp::decoderepconf works on strict (does do replacement)"); |
82 |
| -# Test that if we use non-strict mode, it leaves things that fit into Unicode |
83 |
| -# unchanged. |
84 |
| -is(nqp::decoderepconf($special_windows1252, 'windows-1252', 'X', 1), "\c[129]", |
85 |
| - "nqp::decoderepconf(…,1) doesn't replace if byte fits into unicode"); |
86 |
| - |
87 | 66 | is(nqp::decode($replaced_latin1, 'windows-1252'), 'XXXfooXXXbarå', 'nqp::encoderep works with windows-1252');
|
88 | 67 |
|
89 | 68 |
|
90 |
| - |
91 | 69 | my $pi_unsigned := $buf8.new;
|
92 | 70 | nqp::push_i($pi_unsigned, 207);
|
93 | 71 | nqp::push_i($pi_unsigned, 128);
|
|
0 commit comments