Skip to content
Snippets Groups Projects
Commit 32159b5b authored by lucien.noel's avatar lucien.noel
Browse files

commit init

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 325 additions and 0 deletions
programme Program
entier x;
booleen z;
debutprg
x = z;
finprg
programme Program
entier x;
booleen z;
debutprg
x = 3 / faux;
finprg
programme Program
constante entier n = 12;
debutprg
n = 30992;
finprg
programme Program
debutprg
si 42 alors
ecrire "vrai";
finsi
finprg
#!/usr/bin/env bash
RUN_SCRIPT=./run.sh
TESTS=11
#Param: base dir, fileName, result dir
testCode () {
RESULT_BASE_FILE=$3/$2
BASE_FILE=$1/$2
CODE_FILE=$BASE_FILE.input
SOURCECODE_FILE=$BASE_FILE.source
BYTECODE_FILE=$BASE_FILE.bytecode
STDIN_FILE=$BASE_FILE.stdin
OUTPUT_FILE=$BASE_FILE.output
echo "Test $BASE_FILE:"
########################################################################## SourceCode
SOURCECODE=
SOURCECODE=$(sh $RUN_SCRIPT source $CODE_FILE)
echo -e "$SOURCECODE" > $RESULT_BASE_FILE.source
sh $RUN_SCRIPT source $CODE_FILE > $RESULT_BASE_FILE.source
echo -n " - SourceCode: "
echo -e "$SOURCECODE" | diff - $SOURCECODE_FILE > /dev/null
if [ $? -eq 0 ]; then
echo -en "OK"
else
echo -en "Failed (BUT IT'S MAYBE NORMAL) ! Compare the input file with the xyz.source generated file and see if there is differences in the code or in the order of lines"
fi
echo -en '\n'
########################################################################## Bytecode
BYTECODE=
BYTECODE=$(sh $RUN_SCRIPT bytecode $CODE_FILE)
echo -e "$BYTECODE" > $RESULT_BASE_FILE.bytecode
echo -n " - Bytecode: "
echo -e "$BYTECODE" | diff - $BYTECODE_FILE > /dev/null
if [ $? -eq 0 ]; then
echo -en "OK"
else
echo -en "Failed (BUT IT'S MAYBE NORMAL) ! Your bytecode can be different from ours but the output (next test) must be the same !"
fi
echo -en '\n'
########################################################################## Exec
echo -e "$BYTECODE" | java -jar lib/jasmin.jar -d /tmp /dev/stdin > /dev/null
OUTPUT=
if [ -f $STDIN_FILE ]; then
OUTPUT=$(java -classpath /tmp Program < $STDIN_FILE)
else
OUTPUT=$(java -classpath /tmp Program)
fi
echo -e "$OUTPUT" > $RESULT_BASE_FILE.output
echo -n " - Output: "
echo -e "$OUTPUT" | diff - $OUTPUT_FILE > /dev/null
if [ $? -eq 0 ]; then
echo -en "OK"
else
echo -en "Failed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
fi
echo -en '\n'
}
echo "=== TEST COMPILATION & EXECUTION ==="
CURRENT_DIR=Tests
RESULT_DIR=$CURRENT_DIR/results
rm -r $RESULT_DIR
mkdir $RESULT_DIR
for i in `eval echo {1..$TESTS}`
do
testCode $CURRENT_DIR test_${i} $RESULT_DIR
done
.class public Program
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 20000
.limit locals 1
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Hello world!"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 1234567
invokevirtual java/io/PrintStream/println(I)V
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 1
ifeq label_0
ldc "vrai"
goto label_1
label_0:
ldc "faux"
label_1:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc 0
ifeq label_2
ldc "vrai"
goto label_3
label_2:
ldc "faux"
label_3:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
exit_label:
return
.end method
programme Program
debutprg
ecrire "Hello world!";
ecrire 1234567;
ecrire vrai;
ecrire faux;
finprg
Hello world!
1234567
vrai
faux
programme Program
debutprg
ecrire "Hello world!";
ecrire 1234567;
ecrire vrai;
ecrire faux;
finprg
.class public Program
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 20000
.limit locals 2
.var 0 is x Z
ldc 0
istore 0
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Enter a boolen:"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
new java/util/Scanner
dup
getstatic java/lang/System/in Ljava/io/InputStream;
invokespecial java/util/Scanner/<init>(Ljava/io/InputStream;)V
invokevirtual java/util/Scanner/nextInt()I
istore 0
getstatic java/lang/System/out Ljava/io/PrintStream;
ldc "Result of not operator:"
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 0
ifeq label_0
iconst_0
goto label_1
label_0:
iconst_1
label_1:
ifeq label_2
ldc "vrai"
goto label_3
label_2:
ldc "faux"
label_3:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
exit_label:
return
.end method
programme Program
booleen x;
debutprg
ecrire "Enter a boolen:";
lire x;
ecrire "Result of not operator:";
ecrire non x;
finprg
Enter a boolen:
Result of not operator:
faux
programme Program
booleen x;
debutprg
ecrire "Enter a boolen:";
lire x;
ecrire "Result of not operator:";
ecrire non x;
finprg
1
\ No newline at end of file
.class public Program
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 20000
.limit locals 3
.var 0 is n I
ldc 12
istore 0
.var 1 is b Z
ldc 1
istore 1
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 0
invokevirtual java/io/PrintStream/println(I)V
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 1
ifeq label_0
ldc "vrai"
goto label_1
label_0:
ldc "faux"
label_1:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
exit_label:
return
.end method
programme Program
constante entier n = 12;
constante booleen b = vrai;
debutprg
ecrire n;
ecrire b;
finprg
\ No newline at end of file
12
vrai
programme Program
constant entier n = 12;
constant booleen b = vrai;
debutprg
ecrire n;
ecrire b;
finprg
.class public Program
.super java/lang/Object
.method public static main([Ljava/lang/String;)V
.limit stack 20000
.limit locals 4
.var 0 is x I
ldc 0
istore 0
.var 1 is y I
ldc 0
istore 1
.var 2 is z Z
ldc 0
istore 2
ldc 23456789
istore 0
ldc 12
ineg
istore 1
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 0
invokevirtual java/io/PrintStream/println(I)V
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 1
invokevirtual java/io/PrintStream/println(I)V
ldc 1
istore 2
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 2
ifeq label_0
ldc "vrai"
goto label_1
label_0:
ldc "faux"
label_1:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
ldc 0
istore 2
getstatic java/lang/System/out Ljava/io/PrintStream;
iload 2
ifeq label_2
ldc "vrai"
goto label_3
label_2:
ldc "faux"
label_3:
invokevirtual java/io/PrintStream/println(Ljava/lang/String;)V
exit_label:
return
.end method
programme Program
entier x, y;
booleen z;
debutprg
x = 23456789;
y = -12;
ecrire x;
ecrire y;
z = vrai;
ecrire z;
z = faux;
ecrire z;
finprg
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment