1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
prelude!();
/// This was due to a binding optimization introduced in
/// 195b67821e5e3dc9f4f5371a7799d2fd08b43ce7, causing the local binding `x` to
/// simply alias the location of `dx`.
#[test]
fn test_pattern_binding_bug() {
let out: i64 = rune! {
fn foo(dx) {
let x = dx;
for n in 0..10 {
x = (x + dx);
}
x
}
foo(3)
};
assert_eq!(out, 3 * 11);
}
/// Bug where string patterns just do not work when part of a match statement
/// inside of an inst fn call.
#[test]
fn test_string_pattern_in_instance_fn_bug() {
let _: () = rune! {
enum Inst { A, Unknown }
pub fn works() {
let program = [];
let inst = match "a" { "a" => Inst::A, _ => Inst::Unknown };
program.push(inst);
assert_eq!(program, [Inst::A]);
}
pub fn broken() {
let program = [];
program.push(match "a" { "a" => Inst::A, _ => Inst::Unknown });
assert_eq!(program, [Inst::A]);
}
works();
broken();
};
}