#!/bin/sh

source $testsuitedir/lib_test.sh

cat > PROGRAMME << EOP
	:new STR/input
	"-4.5" -> input
	:call func input
	"4.5" -> input
	:call func input
	"3" -> input
	:call func input
	"-3" -> input
	:call func input
	"0" -> input
	:call func input
	:delete input
:label func
	:new USR(real)/dividende, STR/output, USR(real)/diviseur , USR(real)/quotient
	:int_to_real 1 -> dividende
	:str_to_real @:current -> diviseur
	:real_positive @diviseur "positive"
	:real_negation @diviseur -> diviseur
:label positive
	:real_division @dividende @diviseur -> quotient
	:real_to_str @quotient -> output
	:write :stdout ~s @output
	:write :stdout ~s "\n"
	:delete dividende, output, diviseur, quotient
	:return
EOP

cat > MEMOIRE_INITIALE << EOM
# Memory:
# Aliases:
# Free addresses:
# Free blocks:
# End of memory
EOM

cat > MEMOIRE_REF << EOM
# Memory:
# Aliases:
# Free addresses:
# Free blocks:
# End of memory
EOM

cat > STDOUT_REF << EOS
0.222222
0.222222
0.333333
0.333333
EOS

cat > STDERR_REF << EOS
+---------------------------------------------------------------------------+
| File PROGRAMME.setlggasm, line 20 > Runtime error (FPE): Division by zero |
+---------------------------------------------------------------------------+
EOS

cat > CODE_RETOUR_REF << EOC
129
EOC

test_basique -p ${builddir}/src/machine/plugin/officiels/.libs/setlggmachinepluginreal.so
