rokucommunity / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
4 stars 2 forks source link

Make `if` behavior when using numeric variables consistent with Roku #35

Closed lvcabral closed 3 months ago

lvcabral commented 8 months ago
sub main()
    a = { bolFalse: false, bolTrue: true, intFalse: 0, intTrue: 1 }
    print a
    print "Positive Test Bool"
    if a.bolFalse then print "True" else print "False"
    if a.bolTrue then print "True" else print "False"
    print "Positive Test Int"
    if a.intFalse then print "True" else print "False"
    if a.intTrue then print "True" else print "False"
    print "Negative Test Bool"
    if not a.bolFalse then print "True" else print "False"
    if not a.bolTrue then print "True" else print "False"
    print "Negative Test Int"
    if not a.intFalse then print "True" else print "False"
    if not a.intTrue then print "True" else print "False"
end sub

The actual ROKU output is:


<Component: roAssociativeArray> =
{
    bolfalse: false
    boltrue: true
    intfalse: 0
    inttrue: 1
}
Positive Test Bool
False
True
Positive Test Int
False
True
Negative Test Bool
True
False
Negative Test Int
True
True

And the current BRS output is:

<Component: roAssociativeArray> =
{
    bolFalse: false
    bolTrue: true
    intFalse: 0
    intTrue: 1
}
Positive Test Bool
False
True
Positive Test Int
False
False
Negative Test Bool
True
False
Negative Test Int
/Users/cabralmb/Repos/brs-emu/test/emulator/if-integer-test.brs(14,7-10): Attempting to NOT non-boolean value.
                            value type: Integer
lvcabral commented 3 months ago

Addressed by #50 and #51