/src/test/run-fail/vec-underrun.rs

http://github.com/jruderman/rust · Rust · 11 lines · 6 code · 2 blank · 3 comment · 2 complexity · 2efeea700feb8d677659bd3da42a73e1 MD5 · raw file

  1. // -*- rust -*-
  2. // error-pattern:bounds check
  3. fn main() {
  4. let v: ~[int] = ~[10, 20];
  5. let x: int = 0;
  6. assert (v[x] == 10);
  7. // Bounds-check failure.
  8. assert (v[x - 1] == 20);
  9. }