@@ -58,26 +58,50 @@ is(buf_dump($buf), '0x00 0x80 0x00 0x00 0x00', 'nqp::writeuint - 32bit big endia
58
58
# work around NQP's literals defaulting to num
59
59
my uint64 $ val := nqp ::bitor_i(nqp ::bitshiftl_i(0x01234567 , 32 ), 0x89ABCDEF );
60
60
$ buf := Buffer. new ;
61
- nqp ::writeuint($ buf , 1 , $ val , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_64_BIT);
61
+
62
+ if nqp ::backendconfig(){" intvalsize" } < 8 {
63
+ nqp ::writeuint($ buf , 1 , 0x89ABCDEF , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_32_BIT);
64
+ nqp ::writeuint($ buf , 5 , 0x01234567 , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_32_BIT);
65
+ }
66
+ else {
67
+ nqp ::writeuint($ buf , 1 , $ val , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_64_BIT);
68
+ }
62
69
63
70
is (buf_dump($ buf ), ' 0x00 0xEF 0xCD 0xAB 0x89 0x67 0x45 0x23 0x01' , ' nqp::writeuint with 64bit little endian' );
64
71
65
72
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_LITTLE), 0xEF , ' read byte' );
66
73
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_16_BIT), 0xCDEF , ' read word' );
67
74
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_32_BIT), 0x89ABCDEF , ' read dword' );
68
- is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_64_BIT), $ val , ' read qword' );
75
+
76
+
77
+ if nqp ::backendconfig(){" intvalsize" } < 8 {
78
+ skip (' nqp::readuint with 64bit not supported on <64bit platforms' );
79
+ } else {
80
+ is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_LITTLE +| nqp ::const::BINARY_SIZE_64_BIT), $ val , ' read qword' );
81
+ }
69
82
70
83
is (nqp :: elems ($ buf ), 9 , ' nqp::readuint does not change the size of buffer' );
71
84
72
85
$ buf := Buffer. new ;
73
- nqp ::writeuint($ buf , 1 , $ val , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_64_BIT);
86
+
87
+ if nqp ::backendconfig(){" intvalsize" } < 8 {
88
+ nqp ::writeuint($ buf , 1 , 0x01234567 , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_32_BIT);
89
+ nqp ::writeuint($ buf , 5 , 0x89ABCDEF , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_32_BIT);
90
+ }
91
+ else {
92
+ nqp ::writeuint($ buf , 1 , $ val , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_64_BIT);
93
+ }
74
94
75
95
is (buf_dump($ buf ), ' 0x00 0x01 0x23 0x45 0x67 0x89 0xAB 0xCD 0xEF' , ' nqp::writeuint with 64bit big endian' );
76
96
77
97
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_BIG), 0x01 , ' read big endian byte' );
78
98
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_16_BIT), 0x0123 , ' read big endian word' );
79
99
is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_32_BIT), 0x01234567 , ' read big endian dword' );
80
- is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_64_BIT), $ val , ' read big endian qword' );
100
+ if nqp ::backendconfig(){" intvalsize" } < 8 {
101
+ skip (' nqp::readuint with 64bit not supported on <64bit platforms' );
102
+ } else {
103
+ is (nqp ::readuint($ buf , 1 , nqp ::const::BINARY_ENDIAN_BIG +| nqp ::const::BINARY_SIZE_64_BIT), $ val , ' read big endian qword' );
104
+ }
81
105
is (nqp :: elems ($ buf ), 9 , ' nqp::readuint does not change the size of buffer' );
82
106
83
107
$ buf := Buffer. new ;
0 commit comments