mmooore Tests

This commit is contained in:
Marvin Schlegel 2024-07-03 16:32:54 +02:00
parent f7d135cdd6
commit 30288731d3
3 changed files with 37 additions and 0 deletions

View File

@ -17,6 +17,7 @@ public class Main {
TestMalicious malicious = new TestMalicious();
TestLoop loop = new TestLoop();
TestMethodOverload overload = new TestMethodOverload();
TestShenanigance shenanigance = new TestShenanigance();
// constructing a basic class works
assert empty != null;
@ -35,6 +36,7 @@ public class Main {
// self-referencing methods work.
assert recursion.fibonacci(15) == 610;
assert loop.factorial(5) == 120;
assert loop.weirdFor() == 5;
// methods with the same name but different parameters work
assert overload.MethodOverload() == 42;
assert overload.MethodOverload(15) == 42 + 15;
@ -48,5 +50,8 @@ public class Main {
{
assert malicious.cursedFormatting(i) == i;
}
assert shenanigance.testAssignment() == 5;
assert shenanigance.divEqual() == 234_343_000 / 4;
assert shenanigance.testIf(5);
}
}

View File

@ -9,4 +9,11 @@ public class TestLoop {
return tally;
}
int weirdFor() {
int k = 0;
for (; k < 5; k++) {
}
return k;
}
}

View File

@ -0,0 +1,25 @@
class TestShenanigance {
int testAssignment() {
int x = 1;
int y = x = 5;
return y;
}
int divEqual() {
int x = 234_343_000;
x /= 4;
return x;
}
boolean testIf(int x) {
if (true && x < 8) {
char f = 'c';
return f > x ;
}
ifn't {
return false;
}
}
}