Boa: Assignment operator not working in tests (a = a +1)

Created on 13 Apr 2020  路  2Comments  路  Source: boa-dev/boa

While implementing do..while loop i've noticed strange boa behavior. This test

#[test]
fn test_while_loop() {
    let src = r#"
        let a = 0;
        while (a < 10) a = a + 1;
        a
    "#;
    assert_eq!(exec(src), String::from("10"));
}

will run forever. Changing loop body to a += 1 makes test pass. Seems like using a = a + 1 does not assign rvalue to lvalue. This test fails too:

#[test]
fn test_addition() {
    let src = r#"
        let a = 0;
        a = a + 1;
        a
    "#;
    assert_eq!(exec(src), String::from("1"));
}

I haven't looked at it yet, as i have limited debug possibilities now (vs code in wsl remote mode does not support lldb and i can't build boa on native windows cause of some problem with jemalloc compilation). Waiting for wsl2.

And second thought: maybe it would be interesting to implement some timeout in tests, i found something looking good here: https://users.rust-lang.org/t/limit-execution-time-of-test/6687/3

bug parser

Most helpful comment

Good news! Found the bug. I will create a pr as soon as possible.

All 2 comments

Hmmm. Interesting, I will take look to see what causing this.

Good news! Found the bug. I will create a pr as soon as possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwilliams picture jasonwilliams  路  10Comments

jasonwilliams picture jasonwilliams  路  12Comments

jasonwilliams picture jasonwilliams  路  24Comments

HalidOdat picture HalidOdat  路  18Comments

raskad picture raskad  路  11Comments