mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-26 17:18:04 +00:00
Merge branch 'refs/heads/testsuites'
This commit is contained in:
commit
4c07efa911
@ -35,6 +35,7 @@
|
||||
(so würde z.B. (true || false == false) false zurückgeben)
|
||||
- i++ und i-- sind nur in for-Schleifen oder Statements erlaubt, --i und ++i sind generell nicht erlaubt
|
||||
- ein File kann nur eine Klasse enthalten
|
||||
- Datentypen sind auf int, boolean und char sowie Klassen beschränkt
|
||||
|
||||
|
||||
## Aufbau der Tests
|
||||
|
@ -167,7 +167,7 @@ public class E2E_Main {
|
||||
Assertions.assertNull(returnValue);
|
||||
Assertions.assertEquals(3, byteArrayOutputStream.toString().length());
|
||||
// durch die newline wird die Ausgabe um 2 Zeichen länger
|
||||
Assertions.assertEquals("3", byteArrayOutputStream.toString().substring(0, byteArrayOutputStream.toString().length() - 2));
|
||||
Assertions.assertEquals("3", byteArrayOutputStream.toString().substring(0, 1));
|
||||
System.setOut(originalOut);
|
||||
} catch (Exception e) {
|
||||
Assertions.fail();
|
||||
|
@ -143,7 +143,7 @@ public class E2E_Print {
|
||||
Assertions.assertNull(returnValue);
|
||||
Assertions.assertEquals(3, byteArrayOutputStream.toString().length());
|
||||
// durch die newline wird die Ausgabe um 2 Zeichen länger
|
||||
Assertions.assertEquals("a", byteArrayOutputStream.toString().substring(0, byteArrayOutputStream.toString().length() - 2));
|
||||
Assertions.assertEquals("a", byteArrayOutputStream.toString().substring(0, 1));
|
||||
System.setOut(originalOut);
|
||||
} catch (Exception e) {
|
||||
Assertions.fail();
|
||||
@ -165,7 +165,7 @@ public class E2E_Print {
|
||||
Assertions.assertNull(returnValue);
|
||||
Assertions.assertEquals(6, byteArrayOutputStream.toString().length());
|
||||
// durch die newline wird die Ausgabe um 2 Zeichen länger
|
||||
Assertions.assertEquals("true", byteArrayOutputStream.toString().substring(0, byteArrayOutputStream.toString().length() - 2));
|
||||
Assertions.assertEquals("true", byteArrayOutputStream.toString().substring(0, 4));
|
||||
System.setOut(originalOut);
|
||||
} catch (Exception e) {
|
||||
Assertions.fail();
|
||||
|
202
src/test/testFiles/AllFeaturesAtOnce/AllFeaturesInOne.java
Normal file
202
src/test/testFiles/AllFeaturesAtOnce/AllFeaturesInOne.java
Normal file
@ -0,0 +1,202 @@
|
||||
public class AllFeaturesInOne {
|
||||
// This is a comment
|
||||
int repititionsOfSchema;
|
||||
int maxLengthOfSchema;
|
||||
char letter1;
|
||||
char letter2;
|
||||
char letter3;
|
||||
boolean doStillExecuteAfterMaxLength;
|
||||
Configuration configuration;
|
||||
|
||||
public AllFeaturesInOne() {
|
||||
this.letter1 = 'a';
|
||||
this.letter2 = 'b';
|
||||
this.letter3 = 'c';
|
||||
this.maxLengthOfSchema = 100;
|
||||
this.doStillExecuteAfterMaxLength = false;
|
||||
this.repititionsOfSchema = 5;
|
||||
}
|
||||
|
||||
public AllFeaturesInOne(char letter3) {
|
||||
this.letter1 = 'a';
|
||||
this.letter2 = 'b';
|
||||
this.letter3 = letter3;
|
||||
this.maxLengthOfSchema = 100;
|
||||
this.doStillExecuteAfterMaxLength = false;
|
||||
this.repititionsOfSchema = 5;
|
||||
}
|
||||
|
||||
public AllFeaturesInOne(int repititionsOfSchema, char letter3) {
|
||||
this.repititionsOfSchema = repititionsOfSchema;
|
||||
this.letter1 = 'a';
|
||||
this.letter2 = 'b';
|
||||
this.letter3 = letter3;
|
||||
this.maxLengthOfSchema = 100;
|
||||
this.doStillExecuteAfterMaxLength = false;
|
||||
}
|
||||
|
||||
public AllFeaturesInOne(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
this.repititionsOfSchema = configuration.getRepititionsOfSchema();
|
||||
this.maxLengthOfSchema = configuration.maxLengthOfSchema;
|
||||
this.letter1 = configuration.letter1;
|
||||
this.letter2 = configuration.letter2;
|
||||
this.letter3 = configuration.letter3;
|
||||
this.doStillExecuteAfterMaxLength = configuration.doStillExecuteAfterMaxLength;
|
||||
}
|
||||
|
||||
public void printFibonacciSchema(boolean withSpaceBetweenSteps) {
|
||||
int number1 = 0;
|
||||
int number2 = 1;
|
||||
int numberOfLetter = 0;
|
||||
for (int i = 0; i < this.repititionsOfSchema; i++) {
|
||||
if(number2 == this.maxLengthOfSchema && !this.doStillExecuteAfterMaxLength) {
|
||||
break;
|
||||
}
|
||||
int j;
|
||||
for(j = number2; j > 0; j -= 1) {
|
||||
if (numberOfLetter == 0) {
|
||||
print(this.letter1);
|
||||
} else if (numberOfLetter == 1) {
|
||||
print(this.letter2);
|
||||
} else {
|
||||
print(this.letter3);
|
||||
}
|
||||
}
|
||||
if (withSpaceBetweenSteps) {
|
||||
print('L');
|
||||
}
|
||||
numberOfLetter = (numberOfLetter + 1) % 3;
|
||||
int sum = number1 + number2;
|
||||
number1 = number2;
|
||||
number2 = sum;
|
||||
}
|
||||
}
|
||||
|
||||
public void printFibonacciButWithMultiplication() {
|
||||
int number1 = 1;
|
||||
int number2 = 2;
|
||||
int numberOfLetter = 0;
|
||||
for (int i = 0; i < this.repititionsOfSchema; i += 1) {
|
||||
if(number2 <= this.maxLengthOfSchema || this.doStillExecuteAfterMaxLength) {
|
||||
int j;
|
||||
for(j = 0; j < number2; j = j + 1) {
|
||||
if (numberOfLetter == 0) {
|
||||
print(this.letter1);
|
||||
} else if (numberOfLetter == 1) {
|
||||
print(this.letter2);
|
||||
} else {
|
||||
print(this.letter3);
|
||||
}
|
||||
}
|
||||
print('L');
|
||||
numberOfLetter = (numberOfLetter + 1) % 3;
|
||||
int number2OldValue = number2;
|
||||
number2 *= number1;
|
||||
number1 = number2OldValue;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printEveryLetterXTimesAndSkipEveryYTimesComplex(int x, int y) {
|
||||
int numberOfLetter = 0;
|
||||
int rest = 0;
|
||||
int numberOfRepititions;
|
||||
int numberToDivide;
|
||||
int numberOfRepetitionsWithoutSkip = 0;
|
||||
do {
|
||||
numberOfRepititions = (x - rest) - ((x - rest) / y);
|
||||
if (rest > 0) {
|
||||
numberOfRepititions += rest - 1;
|
||||
}
|
||||
rest = (y - ((x + (-rest)) % y)) % y;
|
||||
while (numberOfRepititions > 0) {
|
||||
numberOfRepetitionsWithoutSkip++;
|
||||
if (numberOfRepetitionsWithoutSkip == y) {
|
||||
print('');
|
||||
numberOfRepetitionsWithoutSkip = 0;
|
||||
} else {
|
||||
if (numberOfLetter == 0) {
|
||||
print(this.letter1);
|
||||
} else if (numberOfLetter == 1) {
|
||||
print(this.letter2);
|
||||
} else {
|
||||
print(this.letter3);
|
||||
}
|
||||
}
|
||||
numberOfRepititions--;
|
||||
}
|
||||
numberOfLetter = (numberOfLetter + 1) % 3;
|
||||
} while(rest != 0);
|
||||
}
|
||||
|
||||
public void printEveryLetterXTimesAndSkipEveryYTimesSimple(int x, int y) {
|
||||
int numberOfLetter = 0;
|
||||
int repititionsAbs = 0;
|
||||
while((repititionsAbs % y) != 0 || repititionsAbs == 0) {
|
||||
for (int i = 0; i < x; i++) {
|
||||
repititionsAbs++;
|
||||
if (repititionsAbs % y == 0) {
|
||||
print('L');
|
||||
continue;
|
||||
}
|
||||
if (numberOfLetter == 0) {
|
||||
print(this.letter1);
|
||||
} else if (numberOfLetter == 1) {
|
||||
print(this.letter2);
|
||||
} else {
|
||||
print(this.letter3);
|
||||
}
|
||||
}
|
||||
numberOfLetter = (numberOfLetter + 1) % 3;
|
||||
}
|
||||
}
|
||||
|
||||
public char getLetter2() {
|
||||
return this.letter2;
|
||||
}
|
||||
|
||||
public void setLetter2(char letter2) {
|
||||
this.letter2 = letter2;
|
||||
}
|
||||
|
||||
public int setMaxLengthOfSchema(int maxLengthOfSchema) {
|
||||
this.maxLengthOfSchema = maxLengthOfSchema;
|
||||
return this.maxLengthOfSchema;
|
||||
}
|
||||
|
||||
public void setDoStillExecuteAfterMaxLength(boolean doStillExecuteAfterMaxLength) {
|
||||
this.doStillExecuteAfterMaxLength = doStillExecuteAfterMaxLength;
|
||||
}
|
||||
|
||||
public boolean allLettersAreDifferent() {
|
||||
return this.letter1 != this.letter2 && this.letter1 != this.letter3 && letter2 != this.letter3;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AllFeaturesInOne allFeaturesInOne = new AllFeaturesInOne('d');
|
||||
if (allFeaturesInOne.getLetter2() == 'd') {
|
||||
allFeaturesInOne.setLetter2('i');
|
||||
}
|
||||
allFeaturesInOne.setMaxLengthOfSchema(1000);
|
||||
//should print the fibonacci schema in chars with a space between each step and with 5 steps
|
||||
allFeaturesInOne.printFibonacciSchema(true);
|
||||
|
||||
AllFeaturesInOne allFeaturesInOne2 = new AllFeaturesInOne(6, 'e');
|
||||
allFeaturesInOne2.setDoStillExecuteAfterMaxLength(true);
|
||||
//should print the fibonacci schema in chars with a space between each step and with 6 steps
|
||||
// but with mul instead of sum
|
||||
allFeaturesInOne2.printFibonacciButWithMultiplication();
|
||||
|
||||
Configuration configuration = new Configuration(10, 100, 'f', 'g', 'h', true);
|
||||
AllFeaturesInOne allFeaturesInOne3 = new AllFeaturesInOne(configuration);
|
||||
print(allFeaturesInOne3.allLettersAreDifferent());
|
||||
// these two should print the same thing
|
||||
allFeaturesInOne3.printEveryLetterXTimesAndSkipEveryYTimesComplex(13, 7);
|
||||
allFeaturesInOne3.printEveryLetterXTimesAndSkipEveryYTimesSimple(13, 7);
|
||||
// should print true
|
||||
print(allFeaturesInOne3.configuration.getRepititionsOfSchema() == 10);
|
||||
}
|
||||
}
|
28
src/test/testFiles/AllFeaturesAtOnce/Configuration.java
Normal file
28
src/test/testFiles/AllFeaturesAtOnce/Configuration.java
Normal file
@ -0,0 +1,28 @@
|
||||
public class Configuration {
|
||||
int repititionsOfSchema;
|
||||
int maxLengthOfSchema;
|
||||
char letter1;
|
||||
char letter2;
|
||||
char letter3;
|
||||
boolean doStillExecuteAfterMaxLength;
|
||||
|
||||
public Configuration(
|
||||
int repititionsOfSchema,
|
||||
int maxLengthOfSchema,
|
||||
char letter1,
|
||||
char letter2,
|
||||
char letter3,
|
||||
boolean doStillExecuteAfterMaxLength
|
||||
) {
|
||||
this.repititionsOfSchema = repititionsOfSchema;
|
||||
this.maxLengthOfSchema = maxLengthOfSchema;
|
||||
this.letter1 = letter1;
|
||||
this.letter2 = letter2;
|
||||
this.letter3 = letter3;
|
||||
this.doStillExecuteAfterMaxLength = doStillExecuteAfterMaxLength;
|
||||
}
|
||||
|
||||
public int getRepititionsOfSchema() {
|
||||
return this.repititionsOfSchema;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user