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==DONE==
47--EXPECT--
48int(-1)
49int(-1)
50string(6) "U+0E15"
51string(6) "U+0E31"
52string(6) "U+0E27"
53string(6) "U+0E2D"
54string(6) "U+0E22"
55string(6) "U+0E48"
56string(6) "U+0E32"
57string(6) "U+0E07"
58string(6) "U+0E02"
59string(6) "U+0E49"
60string(6) "U+0E2D"
61string(6) "U+0E04"
62string(6) "U+0E27"
63string(6) "U+0E32"
64string(6) "U+0E21"
65Now backwards
66int(-1)
67string(6) "U+0E21"
68string(6) "U+0E32"
69string(6) "U+0E27"
70string(6) "U+0E04"
71string(6) "U+0E2D"
72string(6) "U+0E49"
73string(6) "U+0E02"
74string(6) "U+0E07"
75string(6) "U+0E32"
76string(6) "U+0E48"
77string(6) "U+0E22"
78string(6) "U+0E2D"
79string(6) "U+0E27"
80string(6) "U+0E31"
81string(6) "U+0E15"
82==DONE==
83