1--TEST--
2IntlCodepointBreakIterator::getLastCodePoint(): basic test
3--SKIPIF--
4<?php
5if (!extension_loaded('intl'))
6    die('skip intl extension not enabled');
7--FILE--
8<?php
9ini_set("intl.error_level", E_WARNING);
10ini_set("intl.default_locale", "pt_PT");
11
12$text = 'ตัวอย่างข้อความ';
13
14$codepoint_it = IntlBreakIterator::createCodePointInstance();
15$codepoint_it->setText($text);
16
17var_dump($codepoint_it->getLastCodePoint());
18//first() and last() don't read codepoint and set the last code point var to -1
19//The pointer is after the last read codepoint if moving forward and
20//before the last read codepoint is moving backwards
21$p = $codepoint_it->first();
22while ($p != IntlBreakIterator::DONE) {
23    $c = $codepoint_it->getLastCodePoint();
24    if ($c > 0)
25        var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint()));
26    else
27        var_dump($c);
28    //it's a post-increment operation as to the codepoint, i.e., it gives the codepoint
29    //starting at the initial position and only then moves the pointer forward
30    $p = $codepoint_it->next();
31}
32
33echo "Now backwards\n";
34$p = $codepoint_it->last();
35while ($p != IntlBreakIterator::DONE) {
36    $c = $codepoint_it->getLastCodePoint();
37    if ($c > 0)
38        var_dump(sprintf('U+%04X', $codepoint_it->getLastCodePoint()));
39    else
40        var_dump($c);
41    $p = $codepoint_it->previous();
42}
43
44
45?>
46--EXPECT--
47int(-1)
48int(-1)
49string(6) "U+0E15"
50string(6) "U+0E31"
51string(6) "U+0E27"
52string(6) "U+0E2D"
53string(6) "U+0E22"
54string(6) "U+0E48"
55string(6) "U+0E32"
56string(6) "U+0E07"
57string(6) "U+0E02"
58string(6) "U+0E49"
59string(6) "U+0E2D"
60string(6) "U+0E04"
61string(6) "U+0E27"
62string(6) "U+0E32"
63string(6) "U+0E21"
64Now backwards
65int(-1)
66string(6) "U+0E21"
67string(6) "U+0E32"
68string(6) "U+0E27"
69string(6) "U+0E04"
70string(6) "U+0E2D"
71string(6) "U+0E49"
72string(6) "U+0E02"
73string(6) "U+0E07"
74string(6) "U+0E32"
75string(6) "U+0E48"
76string(6) "U+0E22"
77string(6) "U+0E2D"
78string(6) "U+0E27"
79string(6) "U+0E31"
80string(6) "U+0E15"
81