compiler/
kernel/
lib/
examples/
std/
arch/
char/
collections/
lang/
sys/
arch.rad
68 B
char.rad
855 B
collections.rad
39 B
fmt.rad
8.1 KiB
intrinsics.rad
467 B
io.rad
1.3 KiB
lang.rad
276 B
mem.rad
2.2 KiB
sys.rad
179 B
testing.rad
2.4 KiB
tests.rad
15.2 KiB
vec.rad
3.2 KiB
std.rad
281 B
scripts/
seed/
sublime/
test/
vim/
.gitignore
351 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
3.8 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.4 KiB
std.lib.test
380 B
lib/std/tests.rad
raw
| 1 | //! Tests for formatting functions. |
| 2 | |
| 3 | use std::fmt; |
| 4 | use std::mem; |
| 5 | use std::vec; |
| 6 | use std::testing; |
| 7 | use std::sys::unix; |
| 8 | |
| 9 | // Data types ////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | record Point: Copy { |
| 12 | x: i32, |
| 13 | y: i32, |
| 14 | } |
| 15 | |
| 16 | // fmt ///////////////////////////////////////////////////////////////////////// |
| 17 | |
| 18 | @test fn testFormatU32Zero() throws (testing::TestError) { |
| 19 | let mut buffer: [u8; 11] = [0; 11]; |
| 20 | let result: *[u8] = fmt::formatU32(0, &mut buffer[..]); |
| 21 | try testing::expect(result.len == 1); |
| 22 | try testing::expectBytesEq(result, "0"); |
| 23 | } |
| 24 | |
| 25 | @test fn testFormatU32Basic() throws (testing::TestError) { |
| 26 | let mut buffer: [u8; 11] = [0; 11]; |
| 27 | let result: *[u8] = fmt::formatU32(123, &mut buffer[..]); |
| 28 | try testing::expect(result.len == 3); |
| 29 | try testing::expectBytesEq(result, "123"); |
| 30 | } |
| 31 | |
| 32 | @test fn testFormatU32Large() throws (testing::TestError) { |
| 33 | let mut buffer: [u8; 11] = [0; 11]; |
| 34 | let result: *[u8] = fmt::formatU32(90000, &mut buffer[..]); |
| 35 | try testing::expect(result.len == 5); |
| 36 | try testing::expectBytesEq(result, "90000"); |
| 37 | } |
| 38 | |
| 39 | @test fn testFormatU32Max() throws (testing::TestError) { |
| 40 | let mut buffer: [u8; 11] = [0; 11]; |
| 41 | let result: *[u8] = fmt::formatU32(4294967295, &mut buffer[..]); |
| 42 | try testing::expect(result.len == 10); |
| 43 | try testing::expectBytesEq(result, "4294967295"); |
| 44 | } |
| 45 | |
| 46 | @test fn testFormatI32Positive() throws (testing::TestError) { |
| 47 | let mut buffer: [u8; 11] = [0; 11]; |
| 48 | let result: *[u8] = fmt::formatI32(456, &mut buffer[..]); |
| 49 | try testing::expect(result.len == 3); |
| 50 | try testing::expectBytesEq(result, "456"); |
| 51 | } |
| 52 | |
| 53 | @test fn testFormatI32Negative() throws (testing::TestError) { |
| 54 | let mut buffer: [u8; 11] = [0; 11]; |
| 55 | let result: *[u8] = fmt::formatI32(-789, &mut buffer[..]); |
| 56 | try testing::expect(result.len == 4); |
| 57 | try testing::expectBytesEq(result, "-789"); |
| 58 | } |
| 59 | |
| 60 | @test fn testFormatI32Zero() throws (testing::TestError) { |
| 61 | let mut buffer: [u8; 11] = [0; 11]; |
| 62 | let result: *[u8] = fmt::formatI32(0, &mut buffer[..]); |
| 63 | try testing::expect(result.len == 1); |
| 64 | try testing::expectBytesEq(result, "0"); |
| 65 | } |
| 66 | |
| 67 | @test fn testFormatI32Max() throws (testing::TestError) { |
| 68 | let mut buffer: [u8; 11] = [0; 11]; |
| 69 | let result: *[u8] = fmt::formatI32(2147483647, &mut buffer[..]); |
| 70 | try testing::expect(result.len == 10); |
| 71 | try testing::expectBytesEq(result, "2147483647"); |
| 72 | } |
| 73 | |
| 74 | @test fn testFormatI32Min() throws (testing::TestError) { |
| 75 | let mut buffer: [u8; 11] = [0; 11]; |
| 76 | let result: *[u8] = fmt::formatI32(-2147483648, &mut buffer[..]); |
| 77 | try testing::expect(result.len == 11); |
| 78 | try testing::expectBytesEq(result, "-2147483648"); |
| 79 | } |
| 80 | |
| 81 | @test fn testFormatU64Zero() throws (testing::TestError) { |
| 82 | let mut buffer: [u8; 20] = [0; 20]; |
| 83 | let result: *[u8] = fmt::formatU64(0, &mut buffer[..]); |
| 84 | try testing::expect(result.len == 1); |
| 85 | try testing::expectBytesEq(result, "0"); |
| 86 | } |
| 87 | |
| 88 | @test fn testFormatU64Max() throws (testing::TestError) { |
| 89 | let mut buffer: [u8; 20] = [0; 20]; |
| 90 | let result: *[u8] = fmt::formatU64(18446744073709551615, &mut buffer[..]); |
| 91 | try testing::expect(result.len == 20); |
| 92 | try testing::expectBytesEq(result, "18446744073709551615"); |
| 93 | } |
| 94 | |
| 95 | @test fn testFormatI64Negative() throws (testing::TestError) { |
| 96 | let mut buffer: [u8; 20] = [0; 20]; |
| 97 | let result: *[u8] = fmt::formatI64(-9876543210, &mut buffer[..]); |
| 98 | try testing::expect(result.len == 11); |
| 99 | try testing::expectBytesEq(result, "-9876543210"); |
| 100 | } |
| 101 | |
| 102 | @test fn testFormatI64Min() throws (testing::TestError) { |
| 103 | let mut buffer: [u8; 20] = [0; 20]; |
| 104 | let result: *[u8] = fmt::formatI64(-9223372036854775808, &mut buffer[..]); |
| 105 | try testing::expect(result.len == 20); |
| 106 | try testing::expectBytesEq(result, "-9223372036854775808"); |
| 107 | } |
| 108 | |
| 109 | @test fn testParseIntLiteralText() throws (testing::TestError) { |
| 110 | let dec = try fmt::parseInt("123") catch { |
| 111 | throw testing::TestError::Failed; |
| 112 | }; |
| 113 | try testing::expect(dec.magnitude == 123); |
| 114 | try testing::expect(dec.radix == fmt::Radix::Decimal); |
| 115 | |
| 116 | let hex = try fmt::parseInt("0x2a") catch { |
| 117 | throw testing::TestError::Failed; |
| 118 | }; |
| 119 | try testing::expect(hex.magnitude == 42); |
| 120 | try testing::expect(hex.radix == fmt::Radix::Hex); |
| 121 | |
| 122 | let bin = try fmt::parseInt("0b101") catch { |
| 123 | throw testing::TestError::Failed; |
| 124 | }; |
| 125 | try testing::expect(bin.magnitude == 5); |
| 126 | try testing::expect(bin.radix == fmt::Radix::Binary); |
| 127 | } |
| 128 | |
| 129 | @test fn testDigitFromAscii() throws (testing::TestError) { |
| 130 | let zero = fmt::digitFromAscii('0', 10) else throw testing::TestError::Failed; |
| 131 | try testing::expect(zero == 0); |
| 132 | |
| 133 | let nine = fmt::digitFromAscii('9', 10) else throw testing::TestError::Failed; |
| 134 | try testing::expect(nine == 9); |
| 135 | |
| 136 | let lower = fmt::digitFromAscii('a', 16) else throw testing::TestError::Failed; |
| 137 | try testing::expect(lower == 10); |
| 138 | |
| 139 | let lowerF = fmt::digitFromAscii('f', 16) else throw testing::TestError::Failed; |
| 140 | try testing::expect(lowerF == 15); |
| 141 | |
| 142 | let upper = fmt::digitFromAscii('A', 16) else throw testing::TestError::Failed; |
| 143 | try testing::expect(upper == 10); |
| 144 | |
| 145 | let upperF = fmt::digitFromAscii('F', 16) else throw testing::TestError::Failed; |
| 146 | try testing::expect(upperF == 15); |
| 147 | |
| 148 | try testing::expect(fmt::digitFromAscii('g', 16) == nil); |
| 149 | try testing::expect(fmt::digitFromAscii('_', 10) == nil); |
| 150 | } |
| 151 | |
| 152 | @test fn testParseIntLiteralTextErrors() throws (testing::TestError) { |
| 153 | try fmt::parseInt("") catch { |
| 154 | return; |
| 155 | }; |
| 156 | throw testing::TestError::Failed; |
| 157 | } |
| 158 | |
| 159 | @test fn testParseIntLiteralTextRejectsSigns() throws (testing::TestError) { |
| 160 | try fmt::parseInt("-1") catch { |
| 161 | try fmt::parseInt("+1") catch { |
| 162 | return; |
| 163 | }; |
| 164 | }; |
| 165 | throw testing::TestError::Failed; |
| 166 | } |
| 167 | |
| 168 | @test fn testParseIntLiteralTextInvalidDigitErrors() throws (testing::TestError) { |
| 169 | try fmt::parseInt("0b2") catch { |
| 170 | return; |
| 171 | }; |
| 172 | throw testing::TestError::Failed; |
| 173 | } |
| 174 | |
| 175 | @test fn testParseIntLiteralTextOverflowErrors() throws (testing::TestError) { |
| 176 | try fmt::parseInt("18446744073709551616") catch { |
| 177 | return; |
| 178 | }; |
| 179 | throw testing::TestError::Failed; |
| 180 | } |
| 181 | |
| 182 | @test fn testParseCharLiteralText() throws (testing::TestError) { |
| 183 | let x = try fmt::parseChar("'x'") catch { |
| 184 | throw testing::TestError::Failed; |
| 185 | }; |
| 186 | try testing::expect(x == 'x'); |
| 187 | |
| 188 | let newline = try fmt::parseChar("'\\n'") catch { |
| 189 | throw testing::TestError::Failed; |
| 190 | }; |
| 191 | try testing::expect(newline == '\n'); |
| 192 | } |
| 193 | |
| 194 | @test fn testParseCharLiteralTextErrors() throws (testing::TestError) { |
| 195 | try fmt::parseChar("''") catch { |
| 196 | return; |
| 197 | }; |
| 198 | throw testing::TestError::Failed; |
| 199 | } |
| 200 | |
| 201 | @test fn testUnescapeString() throws (testing::TestError) { |
| 202 | let mut buffer: [u8; 8] = [0; 8]; |
| 203 | let len = fmt::unescapeString("a\\n\\0", &mut buffer[..]); |
| 204 | |
| 205 | try testing::expect(len == 3); |
| 206 | try testing::expect(buffer[0] == 'a'); |
| 207 | try testing::expect(buffer[1] == '\n'); |
| 208 | try testing::expect(buffer[2] == 0); |
| 209 | } |
| 210 | |
| 211 | // mem ///////////////////////////////////////////////////////////////////////// |
| 212 | |
| 213 | @test fn testCopyFullSlice() throws (testing::TestError) { |
| 214 | let mut xs: [u8; 3] = [1, 2, 3]; |
| 215 | let mut ys: [u8; 3] = [4, 5, 6]; |
| 216 | |
| 217 | try! mem::copy(&mut xs[..], &ys[..]); |
| 218 | try testing::expectBytesEq(&xs[..], &ys[..]); |
| 219 | try testing::expectBytesEq(&xs[..], &[4, 5, 6]); |
| 220 | } |
| 221 | |
| 222 | @test fn testCopyPartialSlice() throws (testing::TestError) { |
| 223 | let mut xs: [u8; 3] = [1, 2, 3]; |
| 224 | |
| 225 | try! mem::copy(&mut xs[..2], &[8, 9]); |
| 226 | try testing::expectBytesEq(&xs[..], &[8, 9, 3]); |
| 227 | } |
| 228 | |
| 229 | @test fn testCopySingleElement() throws (testing::TestError) { |
| 230 | let mut xs: [u8; 3] = [1, 2, 3]; |
| 231 | |
| 232 | try! mem::copy(&mut xs[..], &[7]); |
| 233 | try testing::expectBytesEq(&xs[..], &[7, 2, 3]); |
| 234 | } |
| 235 | |
| 236 | @test fn testCopyBufferTooSmallError() throws (testing::TestError) { |
| 237 | let mut xs: [u8; 2] = [1, 2]; |
| 238 | let ys: [u8; 3] = [4, 5, 6]; |
| 239 | |
| 240 | let mut threw = false; |
| 241 | try mem::copy(&mut xs[..], &ys[..]) catch { |
| 242 | set threw = true; |
| 243 | }; |
| 244 | try testing::expect(threw); |
| 245 | } |
| 246 | |
| 247 | @test fn testWriteFileParts() throws (testing::TestError) { |
| 248 | let path = "/tmp/radiance-std-write-file-parts.test"; |
| 249 | let mut buffer: [u8; 16] = undefined; |
| 250 | |
| 251 | if not unix::writeFileParts(path, &["hello", " ", "world"]) { |
| 252 | throw testing::TestError::Failed; |
| 253 | } |
| 254 | let data = unix::readFile(path, &mut buffer[..]) else { |
| 255 | throw testing::TestError::Failed; |
| 256 | }; |
| 257 | try testing::expectBytesEq(data, "hello world"); |
| 258 | } |
| 259 | |
| 260 | @test fn testStripPrefixMatch() throws (testing::TestError) { |
| 261 | let input: *[u8] = "hello world"; |
| 262 | let prefix: *[u8] = "hello"; |
| 263 | |
| 264 | let result = mem::stripPrefix(prefix, input) else { |
| 265 | throw testing::TestError::Failed; |
| 266 | }; |
| 267 | try testing::expectBytesEq(result, " world"); |
| 268 | } |
| 269 | |
| 270 | @test fn testStripPrefixNoMatch() throws (testing::TestError) { |
| 271 | let input: *[u8] = "hello world"; |
| 272 | let prefix: *[u8] = "goodbye"; |
| 273 | |
| 274 | let result = mem::stripPrefix(prefix, input); |
| 275 | try testing::expect(result == nil); |
| 276 | } |
| 277 | |
| 278 | @test fn testStripPrefixEmpty() throws (testing::TestError) { |
| 279 | let input: *[u8] = "hello"; |
| 280 | let prefix: *[u8] = ""; |
| 281 | |
| 282 | let result = mem::stripPrefix(prefix, input) else { |
| 283 | throw testing::TestError::Failed; |
| 284 | }; |
| 285 | try testing::expectBytesEq(result, input); |
| 286 | } |
| 287 | |
| 288 | @test fn testStripPrefixTooLong() throws (testing::TestError) { |
| 289 | let input: *[u8] = "hi"; |
| 290 | let prefix: *[u8] = "hello"; |
| 291 | |
| 292 | let result = mem::stripPrefix(prefix, input); |
| 293 | try testing::expect(result == nil); |
| 294 | } |
| 295 | |
| 296 | @test fn testEqMatchingSlices() throws (testing::TestError) { |
| 297 | let a: *[u8] = "abc"; |
| 298 | let b: *[u8] = "abc"; |
| 299 | |
| 300 | try testing::expect(mem::eq(a, b)); |
| 301 | } |
| 302 | |
| 303 | @test fn testEqDifferentContents() throws (testing::TestError) { |
| 304 | let a: *[u8] = "abc"; |
| 305 | let b: *[u8] = "abd"; |
| 306 | |
| 307 | try testing::expectNot(mem::eq(a, b)); |
| 308 | } |
| 309 | |
| 310 | @test fn testEqDifferentLengths() throws (testing::TestError) { |
| 311 | let a: *[u8] = "abc"; |
| 312 | let b: *[u8] = "abcd"; |
| 313 | |
| 314 | try testing::expectNot(mem::eq(a, b)); |
| 315 | } |
| 316 | |
| 317 | @test fn testEqEmptySlices() throws (testing::TestError) { |
| 318 | let a: *[u8] = ""; |
| 319 | let b: *[u8] = ""; |
| 320 | |
| 321 | try testing::expect(mem::eq(a, b)); |
| 322 | } |
| 323 | |
| 324 | @test fn testCmpEqualSlices() throws (testing::TestError) { |
| 325 | try testing::expect(mem::cmp("abc", "abc") == 0); |
| 326 | } |
| 327 | |
| 328 | @test fn testCmpLessThanByContent() throws (testing::TestError) { |
| 329 | try testing::expect(mem::cmp("abc", "abd") < 0); |
| 330 | } |
| 331 | |
| 332 | @test fn testCmpGreaterThanByContent() throws (testing::TestError) { |
| 333 | try testing::expect(mem::cmp("abd", "abc") > 0); |
| 334 | } |
| 335 | |
| 336 | @test fn testCmpPrefixOrdering() throws (testing::TestError) { |
| 337 | try testing::expect(mem::cmp("abc", "abcd") < 0); |
| 338 | try testing::expect(mem::cmp("abcd", "abc") > 0); |
| 339 | } |
| 340 | |
| 341 | // vec ///////////////////////////////////////////////////////////////////////// |
| 342 | |
| 343 | @test fn testVecInitialState() throws (testing::TestError) { |
| 344 | let mut arena: [u8; 16] align(4) = undefined; |
| 345 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 346 | |
| 347 | try testing::expect(vec::len(&v) == 0); |
| 348 | try testing::expect(vec::capacity(&v) == 4); |
| 349 | } |
| 350 | |
| 351 | @test fn testVecPushAndGet() throws (testing::TestError) { |
| 352 | let mut arena: [u8; 16] align(4) = undefined; |
| 353 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 354 | |
| 355 | let val1: i32 = 42; |
| 356 | try testing::expect(vec::push(&mut v, &val1)); |
| 357 | try testing::expect(vec::len(&v) == 1); |
| 358 | |
| 359 | let ptr = vec::get(&v, 0) else { |
| 360 | throw testing::TestError::Failed; |
| 361 | }; |
| 362 | let i32ptr: *i32 = ptr as *i32; |
| 363 | let value: i32 = *i32ptr; |
| 364 | try testing::expect(value == 42); |
| 365 | } |
| 366 | |
| 367 | @test fn testVecPushPop() throws (testing::TestError) { |
| 368 | let mut arena: [u8; 16] align(4) = undefined; |
| 369 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 370 | |
| 371 | let val1: i32 = 42; |
| 372 | let val2: i32 = 100; |
| 373 | let val3: i32 = -5; |
| 374 | |
| 375 | try testing::expect(vec::push(&mut v, &val1)); |
| 376 | try testing::expect(vec::len(&v) == 1); |
| 377 | |
| 378 | try testing::expect(vec::push(&mut v, &val2)); |
| 379 | try testing::expect(vec::len(&v) == 2); |
| 380 | |
| 381 | try testing::expect(vec::push(&mut v, &val3)); |
| 382 | try testing::expect(vec::len(&v) == 3); |
| 383 | |
| 384 | let mut popped: i32 = 0; |
| 385 | |
| 386 | try testing::expect(vec::pop(&mut v, &mut popped)); |
| 387 | try testing::expect(popped == -5); |
| 388 | try testing::expect(vec::len(&v) == 2); |
| 389 | |
| 390 | try testing::expect(vec::pop(&mut v, &mut popped)); |
| 391 | try testing::expect(popped == 100); |
| 392 | try testing::expect(vec::len(&v) == 1); |
| 393 | |
| 394 | try testing::expect(vec::pop(&mut v, &mut popped)); |
| 395 | try testing::expect(popped == 42); |
| 396 | try testing::expect(vec::len(&v) == 0); |
| 397 | |
| 398 | try testing::expectNot(vec::pop(&mut v, &mut popped)); |
| 399 | } |
| 400 | |
| 401 | @test fn testVecGetSet() throws (testing::TestError) { |
| 402 | let mut arena: [u8; 32] align(4) = undefined; |
| 403 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 404 | |
| 405 | let val1: i32 = 10; |
| 406 | let val2: i32 = 20; |
| 407 | let val3: i32 = 30; |
| 408 | |
| 409 | vec::push(&mut v, &val1); |
| 410 | vec::push(&mut v, &val2); |
| 411 | vec::push(&mut v, &val3); |
| 412 | |
| 413 | if let ptr = vec::get(&v, 0) { |
| 414 | let value: i32 = *(ptr as *i32); |
| 415 | try testing::expect(value == 10); |
| 416 | } else { |
| 417 | throw testing::TestError::Failed; |
| 418 | } |
| 419 | |
| 420 | if let ptr = vec::get(&v, 1) { |
| 421 | let value: i32 = *(ptr as *i32); |
| 422 | try testing::expect(value == 20); |
| 423 | } else { |
| 424 | throw testing::TestError::Failed; |
| 425 | } |
| 426 | |
| 427 | if let ptr = vec::get(&v, 2) { |
| 428 | let value: i32 = *(ptr as *i32); |
| 429 | try testing::expect(value == 30); |
| 430 | } else { |
| 431 | throw testing::TestError::Failed; |
| 432 | } |
| 433 | try testing::expect(vec::get(&v, 3) == nil); |
| 434 | |
| 435 | let new: i32 = 999; |
| 436 | try testing::expect(vec::put(&mut v, 1, &new)); |
| 437 | |
| 438 | if let ptr = vec::get(&v, 1) { |
| 439 | let value: i32 = *(ptr as *i32); |
| 440 | try testing::expect(value == 999); |
| 441 | } else { |
| 442 | throw testing::TestError::Failed; |
| 443 | } |
| 444 | try testing::expectNot(vec::put(&mut v, 5, &new)); |
| 445 | } |
| 446 | |
| 447 | @test fn testVecCapacity() throws (testing::TestError) { |
| 448 | let mut arena: [u8; 16] align(4) = undefined; |
| 449 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 450 | |
| 451 | let val: i32 = 7; |
| 452 | try testing::expect(vec::push(&mut v, &val)); |
| 453 | try testing::expect(vec::push(&mut v, &val)); |
| 454 | try testing::expect(vec::push(&mut v, &val)); |
| 455 | try testing::expect(vec::push(&mut v, &val)); |
| 456 | try testing::expect(vec::len(&v) == 4); |
| 457 | |
| 458 | try testing::expectNot(vec::push(&mut v, &val)); |
| 459 | try testing::expect(vec::len(&v) == 4); |
| 460 | } |
| 461 | |
| 462 | @test fn testVecReset() throws (testing::TestError) { |
| 463 | let mut arena: [u8; 16] align(4) = undefined; |
| 464 | let mut v = vec::new(&mut arena[..], @sizeOf(i32), @alignOf(i32)); |
| 465 | |
| 466 | let val: i32 = 123; |
| 467 | vec::push(&mut v, &val); |
| 468 | vec::push(&mut v, &val); |
| 469 | try testing::expect(vec::len(&v) == 2); |
| 470 | |
| 471 | vec::reset(&mut v); |
| 472 | try testing::expect(vec::len(&v) == 0); |
| 473 | |
| 474 | try testing::expect(vec::push(&mut v, &val)); |
| 475 | try testing::expect(vec::len(&v) == 1); |
| 476 | } |
| 477 | |
| 478 | @test fn testVecStruct() throws (testing::TestError) { |
| 479 | let mut arena: [u8; 64] align(4) = undefined; |
| 480 | let mut v = vec::new(&mut arena[..], @sizeOf(Point), @alignOf(Point)); |
| 481 | |
| 482 | let p1: Point = Point { x: 1, y: 2 }; |
| 483 | let p2: Point = Point { x: 3, y: 4 }; |
| 484 | |
| 485 | try testing::expect(vec::push(&mut v, &p1)); |
| 486 | try testing::expect(vec::push(&mut v, &p2)); |
| 487 | |
| 488 | if let ptr = vec::get(&v, 0) { |
| 489 | let p: *Point = ptr as *Point; |
| 490 | try testing::expect(p.x == 1); |
| 491 | try testing::expect(p.y == 2); |
| 492 | } else { |
| 493 | throw testing::TestError::Failed; |
| 494 | } |
| 495 | let mut popped: Point = Point { x: 0, y: 0 }; |
| 496 | |
| 497 | try testing::expect(vec::pop(&mut v, &mut popped)); |
| 498 | try testing::expect(popped.x == 3); |
| 499 | try testing::expect(popped.y == 4); |
| 500 | } |