uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Exponentiation should have higher precedence than multiplicative operations. #1052

Closed npasserini closed 7 years ago

npasserini commented 7 years ago

If you evaluate

    console.println(4 * 3 ** 2)
}

you will get 144 (=12^2) instead of 36(=4*9) as it should.

juanbono commented 7 years ago

Hi! Should I add a test to ensure that it works?

lgassman commented 7 years ago

I have this test red. I made pull from dev after hackaton and now too (june 9 2017)

@Test
def void exponentiationPrecedence() {
    '''
    assert.equals(24, 3 * 2 ** 3)
    assert.equals(36, 4.0 * 3 ** 2)
    assert.equals(5, 1 + 2 ** 2)
    '''.test
}

org.uqbar.project.wollok.tests.interpreter.WollokComparisonFailure: Expected [24] but found [216] at wollok.lib.assert.equals(expected,actual).(classpath:/wollok/lib.wlk:88) at .(__synthetic0.wpgm:2)

lgassman commented 7 years ago

The problem was solved regenerating xtext artifacts from wollok.xtext file