Skip to content

Instantly share code, notes, and snippets.

@patrickbkr
Created November 30, 2020 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickbkr/e36b87dd4522f74856ea9eb8c6d43046 to your computer and use it in GitHub Desktop.
Save patrickbkr/e36b87dd4522f74856ea9eb8c6d43046 to your computer and use it in GitHub Desktop.
..\install\bin\nqp.exe .\t\hll\06-sprintf.t
1..294
ok 1 - no directives
ok 2 - one %s directive
ok 3 - two %s directives
ok 4 - arguments > directives
ok 5 - got correct exception message
ok 6 - arguments > directives
ok 7 - got correct exception message
ok 8 - directives > arguments
ok 9 - got correct exception message
ok 10 - directives > 0 arguments
ok 11 - got correct exception message
ok 12 - %% escape
ok 13 - unknown directive
ok 14 - got correct exception message
ok 15 - right-justified %s with space padding
ok 16 - right-justified %% with space padding
ok 17 - right-justified %s with 0-padding
ok 18 - right-justified %% with 0-padding
ok 19 - right-justified %s with space padding, star-specified
ok 20 - right-justified %s with 0-padding, star-specified
ok 21 - right-justified %% with space padding, star-specified
ok 22 - right-justified %% with 0-padding, star-specified
ok 23 - left-justified %s with space padding, mix-specified
ok 24 - left-justified %s with space padding, star-specified
ok 25 - left-justified %s with space padding, double-specified
ok 26 - left-justified %d with zero padding, mix-specified
ok 27 - left-justified %d with zero padding, star-specified
ok 28 - left-justified %s with zero padding, mix-specified
ok 29 - left-justified %s with zero padding, star-specified
ok 30 - %s string longer than specified size
ok 31 - %d without size or precision
ok 32 - %d on a float
ok 33 - %d on a negative float
ok 34 - %d on decimal with 0-padding
ok 35 - %d on negative decimal with 0-padding (but nothing to pad)
ok 36 - %d on negative decimal with 0-padding
ok 37 - %d on a positive decimal, space-padding with plus sign
ok 38 - %d on a positive decimal, zero-padding with plus sign
ok 39 - %d on bigint
not ok 40 - %d on negative bigint
# Actual value: <-13190017482579450>
# Expected value: <-13190017482579452>
ok 41 - %c directive
ok 42 - %c directive with space padding
ok 43 - %c directive with non-asci codepoints
ok 44 - %c directive with 0-padding
ok 45 - simple %o
ok 46 - decimal %o
ok 47 - %o with 0-padding
ok 48 - %o with space-padding and leading 0
ok 49 - %o with precision
ok 50 - %o with precision, leading 0 not required
ok 51 - %o with insufficient precision
ok 52 - %o with precision, required leading 0 added
ok 53 - simple %x
ok 54 - simple %x
ok 55 - decimal %x
ok 56 - simple %X
ok 57 - %X, '0X' prepended
ok 58 - %x ,'0x prepended'
ok 59 - %x, hash and width
ok 60 - %x, hash, width and precision
ok 61 - %x, no hash, but width and precision
ok 62 - %x with zero-padding
ok 63 - %x with zero-padding, star-specified
ok 64 - simple %u
ok 65 - decimal %u
ok 66 - max uint32 to %u
ok 67 - simple %B
ok 68 - simple %B with plus sign
ok 69 - %B with 0B prefixed
ok 70 - simple %b
ok 71 - simple %b with plus sign
ok 72 - %b with 0b prefixed
ok 73 - %b right justified using space chars
ok 74 - %b right justified, 0-padding
ok 75 - %b left justified using space chars
ok 76 - %b left justified, 0-padding
ok 77 - simple %b, padded
ok 78 - %b, right justified and precision
ok 79 - %b, left justified and precision
ok 80 - %b, right justified and precision, plus sign
ok 81 - %b, right justified and precision, space char
ok 82 - %b, 0 flag with precision: no effect
ok 83 - %b with precision but no width
ok 84 - %b, precision zero, no value
ok 85 - %b, precision zero, plus sign, no value
ok 86 - %b, precision zero, space char, no value
ok 87 - %b, precision zero, minus, no value
ok 88 - %b, precision zero, hash, no value
ok 89 - %b, width but zero precision
ok 90 - %b, width and precision but zero value
ok 91 - %b, width and precision but zero value
ok 92 - %b, width and precision but zero value
ok 93 - %b, width and precision but zero value, overlong
ok 94 - %b, precision zero and value
ok 95 - %b, precision zero, plus sign and value
ok 96 - %b, precision zero, space char and value
ok 97 - %b, precision zero, hash and value
ok 98 - %b, width, zero precision, no value
ok 99 - %b, width, zero precision but value
ok 100 - %b, width and precision and value
ok 101 - %b, width and precision and value
ok 102 - %b, width and precision and value
ok 103 - %b, width and precision and value
ok 104 - simple %b with zero value
ok 105 - 5.2 %e
ok 106 - 5.2 %e
ok 107 - 5.2 %E
ok 108 - 20.2 %e
ok 109 - 20.2 %E
ok 110 - negative 20.2 %e
ok 111 - negative 20.2 %E
ok 112 - 020.2 %e
ok 113 - 020.2 %E
ok 114 - negative 020.2 %e
ok 115 - negative 020.2 %E
ok 116 - %e defaults to .6
ok 117 - %e handles big numbers
ok 118 - %e handles big negative numbers
not ok 119 - %e handles small numbers
# Actual value: <3.141e-20>
# Expected value: <3.142e-20>
not ok 120 - %e handles small negative numbers
# Actual value: <-3.141e-20>
# Expected value: <-3.142e-20>
ok 121 - %e fills up to precision
ok 122 - 5.2 %f
ok 123 - 5.2 %F
ok 124 - 20.2 %f
ok 125 - 20.2 %F
ok 126 - negative 20.2 %f
ok 127 - negative 20.2 %F
ok 128 - 020.2 %f
ok 129 - 020.2 %F
ok 130 - negative 020.2 %f
ok 131 - negative 020.2 %F
ok 132 - %f defaults to .6
ok 133 - %f fills up to precision
ok 134 - %f fills up to precision
ok 135 - %f fills up to precision
ok 136 - %f handles big numbers
ok 137 - %f handles big negative numbers
ok 138 - %f handles small numbers
ok 139 - %f handles small negative numbers
ok 140 - %.0f of 1.969 should be 2
ok 141 - %.1f of 1.969 should be 2.0
ok 142 - %.2f of 1.969 should be 1.97
ok 143 - %.3f of 1.969 should be 1.969
ok 144 - % .3f of 3.141592 should be " 3.142"
ok 145 - % .3f of -3.141592 should be "-3.142"
ok 146 - %+.3f of 3.141592 should be "+3.142"
ok 147 - %+.3f of -3.141592 should be "-3.142"
ok 148 - 5.2 %g
ok 149 - 5.2 %G
ok 150 - 20.2 %g
ok 151 - 20.2 %G
ok 152 - negative 20.2 %g
ok 153 - negative 20.2 %G
ok 154 - 020.2 %g
ok 155 - 020.2 %G
ok 156 - negative 020.2 %g
ok 157 - negative 020.2 %G
ok 158 - %g defaults to precision .6
ok 159 - %g does not fill up to precision
ok 160 - %g does not fill up to precision
ok 161 - 5.2 %g
ok 162 - 5.2 %G
ok 163 - 20.2 %g
ok 164 - 20.2 %G
ok 165 - negative 20.2 %g
ok 166 - negative 20.2 %G
ok 167 - 20.2 %g
ok 168 - 20.2 %G
ok 169 - negative 20.2 %g
ok 170 - negative 20.2 %G
ok 171 - 020.2 %g
ok 172 - 020.2 %G
ok 173 - negative 020.2 %g
ok 174 - negative 020.2 %G
ok 175 - %g does not fill up to precision
ok 176 - %g does not fill up to precision
ok 177 - %17.3e 2.718281828459e-12
ok 178 - %17.3f 2.718281828459e-12
ok 179 - %17.3g 2.718281828459e-12
ok 180 - %17.3e 2.718281828459e-11
ok 181 - %17.3f 2.718281828459e-11
ok 182 - %17.3g 2.718281828459e-11
ok 183 - %17.3e 2.718281828459e-10
ok 184 - %17.3f 2.718281828459e-10
ok 185 - %17.3g 2.718281828459e-10
ok 186 - %17.3e 2.718281828459e-09
ok 187 - %17.3f 2.718281828459e-09
ok 188 - %17.3g 2.718281828459e-09
ok 189 - %17.3e 2.718281828459e-08
ok 190 - %17.3f 2.718281828459e-08
ok 191 - %17.3g 2.718281828459e-08
ok 192 - %17.3e 2.718281828459e-07
ok 193 - %17.3f 2.718281828459e-07
ok 194 - %17.3g 2.718281828459e-07
ok 195 - %17.3e 2.718281828459e-06
ok 196 - %17.3f 2.718281828459e-06
ok 197 - %17.3g 2.718281828459e-06
ok 198 - %17.3e 2.718281828459e-05
ok 199 - %17.3f 2.718281828459e-05
ok 200 - %17.3g 2.718281828459e-05
ok 201 - %17.3e 2.718281828459e-04
ok 202 - %17.3f 2.718281828459e-04
ok 203 - %17.3g 2.718281828459e-04
ok 204 - %17.3e 2.718281828459e-03
ok 205 - %17.3f 2.718281828459e-03
ok 206 - %17.3g 2.718281828459e-03
ok 207 - %17.3e 2.718281828459e-02
ok 208 - %17.3f 2.718281828459e-02
ok 209 - %17.3g 2.718281828459e-02
ok 210 - %17.3e 2.718281828459e-01
ok 211 - %17.3f 2.718281828459e-01
ok 212 - %17.3g 2.718281828459e-01
ok 213 - %17.3e 2.718281828459e+00
ok 214 - %17.3f 2.718281828459e+00
ok 215 - %17.3g 2.718281828459e+00
ok 216 - %17.3e 2.718281828459e+01
ok 217 - %17.3f 2.718281828459e+01
ok 218 - %17.3g 2.718281828459e+01
ok 219 - %17.3e 2.718281828459e+02
ok 220 - %17.3f 2.718281828459e+02
ok 221 - %17.3g 2.718281828459e+02
ok 222 - %17.3e 2.718281828459e+03
ok 223 - %17.3f 2.718281828459e+03
ok 224 - %17.3g 2.718281828459e+03
ok 225 - %17.3e 2.718281828459e+04
ok 226 - %17.3f 2.718281828459e+04
ok 227 - %17.3g 2.718281828459e+04
ok 228 - %17.3e 2.718281828459e+05
ok 229 - %17.3f 2.718281828459e+05
ok 230 - %17.3g 2.718281828459e+05
ok 231 - %17.3e 2.718281828459e+06
ok 232 - %17.3f 2.718281828459e+06
ok 233 - %17.3g 2.718281828459e+06
ok 234 - %17.3e 2.718281828459e+07
ok 235 - %17.3f 2.718281828459e+07
ok 236 - %17.3g 2.718281828459e+07
ok 237 - %17.3e 2.718281828459e+08
ok 238 - %17.3f 2.718281828459e+08
ok 239 - %17.3g 2.718281828459e+08
ok 240 - %17.3e 2.718281828459e+09
ok 241 - %17.3f 2.718281828459e+09
ok 242 - %17.3g 2.718281828459e+09
ok 243 - %17.3e 2.718281828459e+10
ok 244 - %17.3f 2.718281828459e+10
ok 245 - %17.3g 2.718281828459e+10
ok 246 - %17.3e 2.718281828459e+11
ok 247 - %17.3f 2.718281828459e+11
ok 248 - %17.3g 2.718281828459e+11
ok 249 - %17.3e 2.718281828459e+12
ok 250 - %17.3f 2.718281828459e+12
ok 251 - %17.3g 2.718281828459e+12
ok 252 - %17.3g 3.000000000000e-12
ok 253 - %17.3g 3.000000000000e-11
ok 254 - %17.3g 3.000000000000e-10
ok 255 - %17.3g 3.000000000000e-09
ok 256 - %17.3g 3.000000000000e-08
ok 257 - %17.3g 3.000000000000e-07
ok 258 - %17.3g 3.000000000000e-06
ok 259 - %17.3g 3.000000000000e-05
ok 260 - %17.3g 3.000000000000e-04
ok 261 - %17.3g 3.000000000000e-03
ok 262 - %17.3g 3.000000000000e-02
ok 263 - %17.3g 3.000000000000e-01
ok 264 - %17.3g 3.000000000000e+00
ok 265 - %17.3g 3.000000000000e+01
ok 266 - %17.3g 3.000000000000e+02
ok 267 - %17.3g 3.000000000000e+03
ok 268 - %17.3g 3.000000000000e+04
ok 269 - %17.3g 3.000000000000e+05
ok 270 - %17.3g 3.000000000000e+06
ok 271 - %17.3g 3.000000000000e+07
ok 272 - %17.3g 3.000000000000e+08
ok 273 - %17.3g 3.000000000000e+09
ok 274 - %17.3g 3.000000000000e+10
ok 275 - %17.3g 3.000000000000e+11
ok 276 - %17.3g 3.000000000000e+12
ok 277 - parameter index
ok 278 - parameter index
ok 279 - %f, -0e0
ok 280 - %f, +0e0
ok 281 - %e, -0e0
ok 282 - %e, +0e0
ok 283 - %g, -0e0
ok 284 - %g, +0e0
ok 285 - %.3d
ok 286 - %2.4d
ok 287 - %5.3d
ok 288 - %.0d (non-zero number)
ok 289 - %.0d (number is zero)
ok 290 - %.*d
ok 291 - %2.*d
ok 292 - %5.*d
ok 293 - %.*d (non-zero number)
ok 294 - %.*d (number is zero)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment