]> git.proxmox.com Git - rustc.git/blob - src/tools/miri/tests/run-pass/rust-lang-org.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / miri / tests / run-pass / rust-lang-org.rs
1 // This code is editable and runnable!
2 fn main() {
3 // A simple integer calculator:
4 // `+` or `-` means add or subtract by 1
5 // `*` or `/` means multiply or divide by 2
6
7 let program = "+ + * - /";
8 let mut accumulator = 0;
9
10 for token in program.chars() {
11 match token {
12 '+' => accumulator += 1,
13 '-' => accumulator -= 1,
14 '*' => accumulator *= 2,
15 '/' => accumulator /= 2,
16 _ => { /* ignore everything else */ }
17 }
18 }
19
20 assert_eq!(accumulator, 1);
21 }