diff --git a/experiments/modern/src/maki-interpreter/interpreter.test.js b/experiments/modern/src/maki-interpreter/interpreter.test.js index 5c4f64ed..f758f8d4 100644 --- a/experiments/modern/src/maki-interpreter/interpreter.test.js +++ b/experiments/modern/src/maki-interpreter/interpreter.test.js @@ -79,11 +79,18 @@ describe("can use basic operators", () => { [ "2 + 2 = 4", "2.2 + 2.2 = 4.4", + "4 + 4.4 = 4.4 + 4 (not implict casting)", + "#t + #t = 2", "3 - 2 = 1", "3 - -2 = 5", "3.5 - 2 = 1.5", "2 * 3 = 6", "2 * 1.5 = 3", + "#t * 3 = 3", + "#f * 3 = 0", + "#t * 0.25 = 0.25", + "0.25 * #t = 0.25", + "#f * 0.25 = 0", "6 / 3 = 2", "3 / 2 = 1.5", "5 % 2 = 1", @@ -98,27 +105,36 @@ describe("can use basic operators", () => { "1 < 2", "2 > 1", "[int] 4 = [float] 4.4 (autocasting types)", + "! [float] 4.4 = [int] 4 (not autocasting types)", + "[float] 4.4 != [int] 4 (not autocasting types)", + "! [int] 4 != [float] 4.4 (autocasting types)", "[int] 4 <= [float] 4.4 (autocasting types)", "[int] 4 >= [float] 4.4 (autocasting types)", + "! [float] 4.4 <= [int] 4 (not autocasting types)", + "[float] 4.4 >= [int] 4 (not autocasting types)", "! [int] 4 < [float] 4.4 (autocasting types)", + "! [float] 4.4 < [int] 4 (not autocasting types)", "! [int] 4 > [float] 4.4 (autocasting types)", + "[float] 4.4 > [int] 4 (not autocasting types)", "1++ = 1", "1++ (after incremeent) = 2", "2-- = 2", "2-- (after decrement) = 1", "++1 = 2", - "!f", + "!#f", "!0", - "!1 == 0", - "1 == 1", - "0 == 0", - "1 && 1", - "!(1 && 0)", - "!(0 && 0)", - "1 || 1", - "1 || 0", - "0 || 1", - "!(0 || 0)", + "!1 == #f", + "1 == #t", + "0 == #f", + "#t && #t", + "!(#t && #f)", + "!(#f && #f)", + "#t || #t", + "#t || #f", + "#f || #t", + "!(#f || #f)", + "#t || ++n (doesn't short circuit)", + "!(#f && ++ n) (doesn\'t short circuit)" ].map(successOutputFromMessage) ); }); diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.m b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.m index ab08372f..18f14911 100755 --- a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.m +++ b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.m @@ -16,6 +16,18 @@ System.onScriptLoaded() messageBox("2.2 + 2.2 = 4.4", "Fail", 1, ""); } + if (sum + sumFloat == sumFloat + sum) { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Success", 0, ""); + } else { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Fail", 1, ""); + } + + if (true + true == 2) { + messageBox("#t + #t = 2", "Success", 0, ""); + } else { + messageBox("#t + #t = 2", "Fail", 1, ""); + } + if (3 - 2 == 1) { messageBox("3 - 2 = 1", "Success", 0, ""); } else { @@ -46,6 +58,36 @@ System.onScriptLoaded() messageBox("2 * 1.5 = 3", "Fail", 1, ""); } + if (true * 3 == 3) { + messageBox("#t * 3 = 3", "Success", 0, ""); + } else { + messageBox("#t * 3 = 3", "Fail", 1, ""); + } + + if (false * 3 == 0) { + messageBox("#f * 3 = 0", "Success", 0, ""); + } else { + messageBox("#f * 3 = 0", "Fail", 1, ""); + } + + if (true * 0.25 == 0.25) { + messageBox("#t * 0.25 = 0.25", "Success", 0, ""); + } else { + messageBox("#t * 0.25 = 0.25", "Fail", 1, ""); + } + + if (0.25 * true == 0.25) { + messageBox("0.25 * #t = 0.25", "Success", 0, ""); + } else { + messageBox("0.25 * #t = 0.25", "Fail", 1, ""); + } + + if (false * 0.25 == 0) { + messageBox("#f * 0.25 = 0", "Success", 0, ""); + } else { + messageBox("#f * 0.25 = 0", "Fail", 1, ""); + } + if (6 / 3 == 2) { messageBox("6 / 3 = 2", "Success", 0, ""); } else { @@ -132,6 +174,24 @@ System.onScriptLoaded() messageBox("[int] 4 = [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat == sum)) { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat != sum) { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum != sumFloat)) { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Success", 0, ""); + } else { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Fail", 1, ""); + } + if (sum <= sumFloat) { messageBox("[int] 4 <= [float] 4.4 (autocasting types)", "Success", 0, ""); } else { @@ -144,18 +204,43 @@ System.onScriptLoaded() messageBox("[int] 4 >= [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat <= sum)) { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat >= sum) { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum < sumFloat)) { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat < sum)) { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Fail", 1, ""); + } + if (!(sum > sumFloat)) { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (sumFloat > sum) { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Fail", 1, ""); + } + Int tempOne = 1; if (tempOne++ == one) { messageBox("1++ = 1", "Success", 0, ""); @@ -204,9 +289,9 @@ System.onScriptLoaded() Boolean f = false; if (!f) { - messageBox("!f", "Success", 0, ""); + messageBox("!#f", "Success", 0, ""); } else { - messageBox("!f", "Fail", 1, ""); + messageBox("!#f", "Fail", 1, ""); } if (!0) { @@ -216,62 +301,83 @@ System.onScriptLoaded() } if (!1 == false) { - messageBox("!1 == false", "Success", 0, ""); + messageBox("!1 == #f", "Success", 0, ""); } else { - messageBox("!1 == false", "Fail", 1, ""); + messageBox("!1 == #f", "Fail", 1, ""); } if (1 == true) { - messageBox("1 == true", "Success", 0, ""); + messageBox("1 == #t", "Success", 0, ""); } else { - messageBox("1 == true", "Fail", 1, ""); + messageBox("1 == #t", "Fail", 1, ""); } if (0 == false) { - messageBox("0 == false", "Success", 0, ""); + messageBox("0 == #f", "Success", 0, ""); } else { - messageBox("0 == false", "Fail", 1, ""); + messageBox("0 == #f", "Fail", 1, ""); } if (true && true) { - messageBox("true && true", "Success", 0, ""); + messageBox("#t && #t", "Success", 0, ""); } else { - messageBox("true && true", "Fail", 1, ""); + messageBox("#t && #t", "Fail", 1, ""); } if (!(true && false)) { - messageBox("!(true && false)", "Success", 0, ""); + messageBox("!(#t && #f)", "Success", 0, ""); } else { - messageBox("!(true && false)", "Fail", 1, ""); + messageBox("!(#t && #f)", "Fail", 1, ""); } if (!(false && false)) { - messageBox("!(false && false)", "Success", 0, ""); + messageBox("!(#f && #f)", "Success", 0, ""); } else { - messageBox("!(false && false)", "Fail", 1, ""); + messageBox("!(#f && #f)", "Fail", 1, ""); } if (true || true) { - messageBox("true || true", "Success", 0, ""); + messageBox("#t || #t", "Success", 0, ""); } else { - messageBox("true || true", "Fail", 1, ""); + messageBox("#t || #t", "Fail", 1, ""); } if (true || false) { - messageBox("true || false", "Success", 0, ""); + messageBox("#t || #f", "Success", 0, ""); } else { - messageBox("true || false", "Fail", 1, ""); + messageBox("#t || #f", "Fail", 1, ""); } if (false || true) { - messageBox("false || true", "Success", 0, ""); + messageBox("#f || #t", "Success", 0, ""); } else { - messageBox("false || true", "Fail", 1, ""); + messageBox("#f || #t", "Fail", 1, ""); } if (!(false || false)) { - messageBox("!(false || false)", "Success", 0, ""); + messageBox("!(#f || #f)", "Success", 0, ""); } else { - messageBox("!(false || false)", "Fail", 1, ""); + messageBox("!(#f || #f)", "Fail", 1, ""); + } + + Int n = 1; + if (true || ++n) { + if (n == 2) { + messageBox("#t || ++n (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("#t || ++n (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("#t || ++n", "Fail", 1, ""); + } + + if (!(false && ++n)) { + if (n == 3) { + messageBox("!(#f && ++ n) (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("!(#f && ++ n) (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("!(#f && ++ n)", "Fail", 1, ""); } } diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.maki b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.maki index abdcedf7..7f7c3369 100755 Binary files a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.maki and b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 build 488d)/basicTests.maki differ diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.m b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.m index ab08372f..18f14911 100755 --- a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.m +++ b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.m @@ -16,6 +16,18 @@ System.onScriptLoaded() messageBox("2.2 + 2.2 = 4.4", "Fail", 1, ""); } + if (sum + sumFloat == sumFloat + sum) { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Success", 0, ""); + } else { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Fail", 1, ""); + } + + if (true + true == 2) { + messageBox("#t + #t = 2", "Success", 0, ""); + } else { + messageBox("#t + #t = 2", "Fail", 1, ""); + } + if (3 - 2 == 1) { messageBox("3 - 2 = 1", "Success", 0, ""); } else { @@ -46,6 +58,36 @@ System.onScriptLoaded() messageBox("2 * 1.5 = 3", "Fail", 1, ""); } + if (true * 3 == 3) { + messageBox("#t * 3 = 3", "Success", 0, ""); + } else { + messageBox("#t * 3 = 3", "Fail", 1, ""); + } + + if (false * 3 == 0) { + messageBox("#f * 3 = 0", "Success", 0, ""); + } else { + messageBox("#f * 3 = 0", "Fail", 1, ""); + } + + if (true * 0.25 == 0.25) { + messageBox("#t * 0.25 = 0.25", "Success", 0, ""); + } else { + messageBox("#t * 0.25 = 0.25", "Fail", 1, ""); + } + + if (0.25 * true == 0.25) { + messageBox("0.25 * #t = 0.25", "Success", 0, ""); + } else { + messageBox("0.25 * #t = 0.25", "Fail", 1, ""); + } + + if (false * 0.25 == 0) { + messageBox("#f * 0.25 = 0", "Success", 0, ""); + } else { + messageBox("#f * 0.25 = 0", "Fail", 1, ""); + } + if (6 / 3 == 2) { messageBox("6 / 3 = 2", "Success", 0, ""); } else { @@ -132,6 +174,24 @@ System.onScriptLoaded() messageBox("[int] 4 = [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat == sum)) { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat != sum) { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum != sumFloat)) { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Success", 0, ""); + } else { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Fail", 1, ""); + } + if (sum <= sumFloat) { messageBox("[int] 4 <= [float] 4.4 (autocasting types)", "Success", 0, ""); } else { @@ -144,18 +204,43 @@ System.onScriptLoaded() messageBox("[int] 4 >= [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat <= sum)) { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat >= sum) { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum < sumFloat)) { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat < sum)) { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Fail", 1, ""); + } + if (!(sum > sumFloat)) { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (sumFloat > sum) { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Fail", 1, ""); + } + Int tempOne = 1; if (tempOne++ == one) { messageBox("1++ = 1", "Success", 0, ""); @@ -204,9 +289,9 @@ System.onScriptLoaded() Boolean f = false; if (!f) { - messageBox("!f", "Success", 0, ""); + messageBox("!#f", "Success", 0, ""); } else { - messageBox("!f", "Fail", 1, ""); + messageBox("!#f", "Fail", 1, ""); } if (!0) { @@ -216,62 +301,83 @@ System.onScriptLoaded() } if (!1 == false) { - messageBox("!1 == false", "Success", 0, ""); + messageBox("!1 == #f", "Success", 0, ""); } else { - messageBox("!1 == false", "Fail", 1, ""); + messageBox("!1 == #f", "Fail", 1, ""); } if (1 == true) { - messageBox("1 == true", "Success", 0, ""); + messageBox("1 == #t", "Success", 0, ""); } else { - messageBox("1 == true", "Fail", 1, ""); + messageBox("1 == #t", "Fail", 1, ""); } if (0 == false) { - messageBox("0 == false", "Success", 0, ""); + messageBox("0 == #f", "Success", 0, ""); } else { - messageBox("0 == false", "Fail", 1, ""); + messageBox("0 == #f", "Fail", 1, ""); } if (true && true) { - messageBox("true && true", "Success", 0, ""); + messageBox("#t && #t", "Success", 0, ""); } else { - messageBox("true && true", "Fail", 1, ""); + messageBox("#t && #t", "Fail", 1, ""); } if (!(true && false)) { - messageBox("!(true && false)", "Success", 0, ""); + messageBox("!(#t && #f)", "Success", 0, ""); } else { - messageBox("!(true && false)", "Fail", 1, ""); + messageBox("!(#t && #f)", "Fail", 1, ""); } if (!(false && false)) { - messageBox("!(false && false)", "Success", 0, ""); + messageBox("!(#f && #f)", "Success", 0, ""); } else { - messageBox("!(false && false)", "Fail", 1, ""); + messageBox("!(#f && #f)", "Fail", 1, ""); } if (true || true) { - messageBox("true || true", "Success", 0, ""); + messageBox("#t || #t", "Success", 0, ""); } else { - messageBox("true || true", "Fail", 1, ""); + messageBox("#t || #t", "Fail", 1, ""); } if (true || false) { - messageBox("true || false", "Success", 0, ""); + messageBox("#t || #f", "Success", 0, ""); } else { - messageBox("true || false", "Fail", 1, ""); + messageBox("#t || #f", "Fail", 1, ""); } if (false || true) { - messageBox("false || true", "Success", 0, ""); + messageBox("#f || #t", "Success", 0, ""); } else { - messageBox("false || true", "Fail", 1, ""); + messageBox("#f || #t", "Fail", 1, ""); } if (!(false || false)) { - messageBox("!(false || false)", "Success", 0, ""); + messageBox("!(#f || #f)", "Success", 0, ""); } else { - messageBox("!(false || false)", "Fail", 1, ""); + messageBox("!(#f || #f)", "Fail", 1, ""); + } + + Int n = 1; + if (true || ++n) { + if (n == 2) { + messageBox("#t || ++n (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("#t || ++n (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("#t || ++n", "Fail", 1, ""); + } + + if (!(false && ++n)) { + if (n == 3) { + messageBox("!(#f && ++ n) (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("!(#f && ++ n) (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("!(#f && ++ n)", "Fail", 1, ""); } } diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.maki b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.maki index 8155ba94..a08b95b8 100755 Binary files a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.maki and b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.1.b3 (Winamp 3.0 full)/basicTests.maki differ diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.m b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.m index ab08372f..18f14911 100755 --- a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.m +++ b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.m @@ -16,6 +16,18 @@ System.onScriptLoaded() messageBox("2.2 + 2.2 = 4.4", "Fail", 1, ""); } + if (sum + sumFloat == sumFloat + sum) { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Success", 0, ""); + } else { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Fail", 1, ""); + } + + if (true + true == 2) { + messageBox("#t + #t = 2", "Success", 0, ""); + } else { + messageBox("#t + #t = 2", "Fail", 1, ""); + } + if (3 - 2 == 1) { messageBox("3 - 2 = 1", "Success", 0, ""); } else { @@ -46,6 +58,36 @@ System.onScriptLoaded() messageBox("2 * 1.5 = 3", "Fail", 1, ""); } + if (true * 3 == 3) { + messageBox("#t * 3 = 3", "Success", 0, ""); + } else { + messageBox("#t * 3 = 3", "Fail", 1, ""); + } + + if (false * 3 == 0) { + messageBox("#f * 3 = 0", "Success", 0, ""); + } else { + messageBox("#f * 3 = 0", "Fail", 1, ""); + } + + if (true * 0.25 == 0.25) { + messageBox("#t * 0.25 = 0.25", "Success", 0, ""); + } else { + messageBox("#t * 0.25 = 0.25", "Fail", 1, ""); + } + + if (0.25 * true == 0.25) { + messageBox("0.25 * #t = 0.25", "Success", 0, ""); + } else { + messageBox("0.25 * #t = 0.25", "Fail", 1, ""); + } + + if (false * 0.25 == 0) { + messageBox("#f * 0.25 = 0", "Success", 0, ""); + } else { + messageBox("#f * 0.25 = 0", "Fail", 1, ""); + } + if (6 / 3 == 2) { messageBox("6 / 3 = 2", "Success", 0, ""); } else { @@ -132,6 +174,24 @@ System.onScriptLoaded() messageBox("[int] 4 = [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat == sum)) { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat != sum) { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum != sumFloat)) { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Success", 0, ""); + } else { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Fail", 1, ""); + } + if (sum <= sumFloat) { messageBox("[int] 4 <= [float] 4.4 (autocasting types)", "Success", 0, ""); } else { @@ -144,18 +204,43 @@ System.onScriptLoaded() messageBox("[int] 4 >= [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat <= sum)) { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat >= sum) { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum < sumFloat)) { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat < sum)) { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Fail", 1, ""); + } + if (!(sum > sumFloat)) { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (sumFloat > sum) { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Fail", 1, ""); + } + Int tempOne = 1; if (tempOne++ == one) { messageBox("1++ = 1", "Success", 0, ""); @@ -204,9 +289,9 @@ System.onScriptLoaded() Boolean f = false; if (!f) { - messageBox("!f", "Success", 0, ""); + messageBox("!#f", "Success", 0, ""); } else { - messageBox("!f", "Fail", 1, ""); + messageBox("!#f", "Fail", 1, ""); } if (!0) { @@ -216,62 +301,83 @@ System.onScriptLoaded() } if (!1 == false) { - messageBox("!1 == false", "Success", 0, ""); + messageBox("!1 == #f", "Success", 0, ""); } else { - messageBox("!1 == false", "Fail", 1, ""); + messageBox("!1 == #f", "Fail", 1, ""); } if (1 == true) { - messageBox("1 == true", "Success", 0, ""); + messageBox("1 == #t", "Success", 0, ""); } else { - messageBox("1 == true", "Fail", 1, ""); + messageBox("1 == #t", "Fail", 1, ""); } if (0 == false) { - messageBox("0 == false", "Success", 0, ""); + messageBox("0 == #f", "Success", 0, ""); } else { - messageBox("0 == false", "Fail", 1, ""); + messageBox("0 == #f", "Fail", 1, ""); } if (true && true) { - messageBox("true && true", "Success", 0, ""); + messageBox("#t && #t", "Success", 0, ""); } else { - messageBox("true && true", "Fail", 1, ""); + messageBox("#t && #t", "Fail", 1, ""); } if (!(true && false)) { - messageBox("!(true && false)", "Success", 0, ""); + messageBox("!(#t && #f)", "Success", 0, ""); } else { - messageBox("!(true && false)", "Fail", 1, ""); + messageBox("!(#t && #f)", "Fail", 1, ""); } if (!(false && false)) { - messageBox("!(false && false)", "Success", 0, ""); + messageBox("!(#f && #f)", "Success", 0, ""); } else { - messageBox("!(false && false)", "Fail", 1, ""); + messageBox("!(#f && #f)", "Fail", 1, ""); } if (true || true) { - messageBox("true || true", "Success", 0, ""); + messageBox("#t || #t", "Success", 0, ""); } else { - messageBox("true || true", "Fail", 1, ""); + messageBox("#t || #t", "Fail", 1, ""); } if (true || false) { - messageBox("true || false", "Success", 0, ""); + messageBox("#t || #f", "Success", 0, ""); } else { - messageBox("true || false", "Fail", 1, ""); + messageBox("#t || #f", "Fail", 1, ""); } if (false || true) { - messageBox("false || true", "Success", 0, ""); + messageBox("#f || #t", "Success", 0, ""); } else { - messageBox("false || true", "Fail", 1, ""); + messageBox("#f || #t", "Fail", 1, ""); } if (!(false || false)) { - messageBox("!(false || false)", "Success", 0, ""); + messageBox("!(#f || #f)", "Success", 0, ""); } else { - messageBox("!(false || false)", "Fail", 1, ""); + messageBox("!(#f || #f)", "Fail", 1, ""); + } + + Int n = 1; + if (true || ++n) { + if (n == 2) { + messageBox("#t || ++n (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("#t || ++n (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("#t || ++n", "Fail", 1, ""); + } + + if (!(false && ++n)) { + if (n == 3) { + messageBox("!(#f && ++ n) (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("!(#f && ++ n) (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("!(#f && ++ n)", "Fail", 1, ""); } } diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.maki b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.maki index 6ee8793c..02905f68 100755 Binary files a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.maki and b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.1.13 (Winamp 5.02)/basicTests.maki differ diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.m b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.m index ab08372f..18f14911 100755 --- a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.m +++ b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.m @@ -16,6 +16,18 @@ System.onScriptLoaded() messageBox("2.2 + 2.2 = 4.4", "Fail", 1, ""); } + if (sum + sumFloat == sumFloat + sum) { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Success", 0, ""); + } else { + messageBox("4 + 4.4 = 4.4 + 4 (not implict casting)", "Fail", 1, ""); + } + + if (true + true == 2) { + messageBox("#t + #t = 2", "Success", 0, ""); + } else { + messageBox("#t + #t = 2", "Fail", 1, ""); + } + if (3 - 2 == 1) { messageBox("3 - 2 = 1", "Success", 0, ""); } else { @@ -46,6 +58,36 @@ System.onScriptLoaded() messageBox("2 * 1.5 = 3", "Fail", 1, ""); } + if (true * 3 == 3) { + messageBox("#t * 3 = 3", "Success", 0, ""); + } else { + messageBox("#t * 3 = 3", "Fail", 1, ""); + } + + if (false * 3 == 0) { + messageBox("#f * 3 = 0", "Success", 0, ""); + } else { + messageBox("#f * 3 = 0", "Fail", 1, ""); + } + + if (true * 0.25 == 0.25) { + messageBox("#t * 0.25 = 0.25", "Success", 0, ""); + } else { + messageBox("#t * 0.25 = 0.25", "Fail", 1, ""); + } + + if (0.25 * true == 0.25) { + messageBox("0.25 * #t = 0.25", "Success", 0, ""); + } else { + messageBox("0.25 * #t = 0.25", "Fail", 1, ""); + } + + if (false * 0.25 == 0) { + messageBox("#f * 0.25 = 0", "Success", 0, ""); + } else { + messageBox("#f * 0.25 = 0", "Fail", 1, ""); + } + if (6 / 3 == 2) { messageBox("6 / 3 = 2", "Success", 0, ""); } else { @@ -132,6 +174,24 @@ System.onScriptLoaded() messageBox("[int] 4 = [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat == sum)) { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 = [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat != sum) { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 != [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum != sumFloat)) { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Success", 0, ""); + } else { + messageBox("! [int] 4 != [float] 4.4 (autocasting types)", "Fail", 1, ""); + } + if (sum <= sumFloat) { messageBox("[int] 4 <= [float] 4.4 (autocasting types)", "Success", 0, ""); } else { @@ -144,18 +204,43 @@ System.onScriptLoaded() messageBox("[int] 4 >= [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat <= sum)) { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 <= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (sumFloat >= sum) { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 >= [int] 4 (not autocasting types)", "Fail", 1, ""); + } + + if (!(sum < sumFloat)) { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 < [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (!(sumFloat < sum)) { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("! [float] 4.4 < [int] 4 (not autocasting types)", "Fail", 1, ""); + } + if (!(sum > sumFloat)) { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Success", 0, ""); } else { messageBox("! [int] 4 > [float] 4.4 (autocasting types)", "Fail", 1, ""); } + if (sumFloat > sum) { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Success", 0, ""); + } else { + messageBox("[float] 4.4 > [int] 4 (not autocasting types)", "Fail", 1, ""); + } + Int tempOne = 1; if (tempOne++ == one) { messageBox("1++ = 1", "Success", 0, ""); @@ -204,9 +289,9 @@ System.onScriptLoaded() Boolean f = false; if (!f) { - messageBox("!f", "Success", 0, ""); + messageBox("!#f", "Success", 0, ""); } else { - messageBox("!f", "Fail", 1, ""); + messageBox("!#f", "Fail", 1, ""); } if (!0) { @@ -216,62 +301,83 @@ System.onScriptLoaded() } if (!1 == false) { - messageBox("!1 == false", "Success", 0, ""); + messageBox("!1 == #f", "Success", 0, ""); } else { - messageBox("!1 == false", "Fail", 1, ""); + messageBox("!1 == #f", "Fail", 1, ""); } if (1 == true) { - messageBox("1 == true", "Success", 0, ""); + messageBox("1 == #t", "Success", 0, ""); } else { - messageBox("1 == true", "Fail", 1, ""); + messageBox("1 == #t", "Fail", 1, ""); } if (0 == false) { - messageBox("0 == false", "Success", 0, ""); + messageBox("0 == #f", "Success", 0, ""); } else { - messageBox("0 == false", "Fail", 1, ""); + messageBox("0 == #f", "Fail", 1, ""); } if (true && true) { - messageBox("true && true", "Success", 0, ""); + messageBox("#t && #t", "Success", 0, ""); } else { - messageBox("true && true", "Fail", 1, ""); + messageBox("#t && #t", "Fail", 1, ""); } if (!(true && false)) { - messageBox("!(true && false)", "Success", 0, ""); + messageBox("!(#t && #f)", "Success", 0, ""); } else { - messageBox("!(true && false)", "Fail", 1, ""); + messageBox("!(#t && #f)", "Fail", 1, ""); } if (!(false && false)) { - messageBox("!(false && false)", "Success", 0, ""); + messageBox("!(#f && #f)", "Success", 0, ""); } else { - messageBox("!(false && false)", "Fail", 1, ""); + messageBox("!(#f && #f)", "Fail", 1, ""); } if (true || true) { - messageBox("true || true", "Success", 0, ""); + messageBox("#t || #t", "Success", 0, ""); } else { - messageBox("true || true", "Fail", 1, ""); + messageBox("#t || #t", "Fail", 1, ""); } if (true || false) { - messageBox("true || false", "Success", 0, ""); + messageBox("#t || #f", "Success", 0, ""); } else { - messageBox("true || false", "Fail", 1, ""); + messageBox("#t || #f", "Fail", 1, ""); } if (false || true) { - messageBox("false || true", "Success", 0, ""); + messageBox("#f || #t", "Success", 0, ""); } else { - messageBox("false || true", "Fail", 1, ""); + messageBox("#f || #t", "Fail", 1, ""); } if (!(false || false)) { - messageBox("!(false || false)", "Success", 0, ""); + messageBox("!(#f || #f)", "Success", 0, ""); } else { - messageBox("!(false || false)", "Fail", 1, ""); + messageBox("!(#f || #f)", "Fail", 1, ""); + } + + Int n = 1; + if (true || ++n) { + if (n == 2) { + messageBox("#t || ++n (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("#t || ++n (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("#t || ++n", "Fail", 1, ""); + } + + if (!(false && ++n)) { + if (n == 3) { + messageBox("!(#f && ++ n) (doesn't short circuit)", "Success", 0, ""); + } else { + messageBox("!(#f && ++ n) (did short circuit)", "Fail", 1, ""); + } + } else { + messageBox("!(#f && ++ n)", "Fail", 1, ""); } } diff --git a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.maki b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.maki index 9f9a679f..cef42814 100755 Binary files a/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.maki and b/experiments/modern/src/maki-interpreter/reference/maki_compiler/v1.2.0 (Winamp 5.66)/basicTests.maki differ diff --git a/experiments/modern/src/maki-interpreter/virtualMachine.js b/experiments/modern/src/maki-interpreter/virtualMachine.js index 8fa51627..f2dbfebf 100644 --- a/experiments/modern/src/maki-interpreter/virtualMachine.js +++ b/experiments/modern/src/maki-interpreter/virtualMachine.js @@ -1,12 +1,6 @@ const Variable = require("./variable"); function coerceTypes (var1, var2, val1, val2) { - if (var1.type === 'INT') { - if (var2.type === 'FLOAT' || var2.type === 'DOUBLE') { - return [val1, Math.floor(val2)]; - } - } - if (var2.type === 'INT') { if (var1.type === 'FLOAT' || var1.type === 'DOUBLE') { return [Math.floor(val1), val2];