1--TEST--
2insertData() negative offset (mod 32)
3--EXTENSIONS--
4dom
5--SKIPIF--
6<?php
7if (PHP_INT_SIZE === 4) die('skip not for 32-bit');
8?>
9--FILE--
10<?php
11
12echo "--- Modern behaviour ---\n";
13
14$dom = Dom\HTMLDocument::createEmpty();
15$comment = $dom->createComment("foobarbaz");
16try {
17    $comment->insertData(-1, "A");
18} catch (DOMException $e) {
19    echo $e->getMessage(), "\n";
20}
21echo $dom->saveHtml($comment), "\n";
22$comment->insertData(-(2**32 - 1), "A");
23echo $dom->saveHtml($comment), "\n";
24
25echo "--- Legacy behaviour ---\n";
26
27$dom = new DOMDocument;
28$comment = $dom->createComment("foobarbaz");
29try {
30    $comment->insertData(-1, "A");
31} catch (DOMException $e) {
32    echo $e->getMessage(), "\n";
33}
34echo $dom->saveHtml($comment), "\n";
35try {
36    $comment->insertData(-(2**32 - 1), "A");
37} catch (DOMException $e) {
38    echo $e->getMessage(), "\n";
39}
40echo $dom->saveHtml($comment), "\n";
41
42?>
43--EXPECT--
44--- Modern behaviour ---
45Index Size Error
46<!--foobarbaz-->
47<!--fAoobarbaz-->
48--- Legacy behaviour ---
49Index Size Error
50<!--foobarbaz-->
51Index Size Error
52<!--foobarbaz-->
53