]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/rust-lang-org.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / 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 }