mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 11:04:00 +00:00
More basic tests (#805)
* add more basic tests * add/update passing test strings * only coerce if int is on LHS
This commit is contained in:
parent
4e880ab130
commit
c642b183e7
10 changed files with 539 additions and 105 deletions
|
|
@ -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)
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue