#!/usr/bin/sh
# packages needed:
#
# mono-devel: /usr/bin/mcs
# mono-devel: /usr/bin/csharp
# mono-devel: /usr/bin/monodis

set -e -v -o pipefail

TDIR=debian/tests

# compile, run and disassemble a hello world csharp file
mcs $TDIR/hello.cs
test -x $TDIR/hello.exe
mono $TDIR/hello.exe
mono $TDIR/hello.exe | grep "Hello Mono"

monodis $TDIR/hello.exe | grep "\.assembly 'hello'"

# compile with additional assemblies (not executing)
mcs -pkg:dotnet $TDIR/hello-forms.cs
test -x $TDIR/hello-forms.exe

# recompile bundled MGAN tool and run it
mcs debian/MonoGetAssemblyName.cs
test -x debian/MonoGetAssemblyName.exe
mono debian/MonoGetAssemblyName.exe $(realpath $TDIR/hello.exe) | grep 'hello,'

# try csharp expressions
csharp -e 'print("hello csharp")' | grep 'hello'
