1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/bin/sh
# autopkgtest check: run simple example in the tutorial on the website. This
# works by writing a Java program and putting apfloat.jar in the classpath.
# (C) 2002-2019 Mikko Tommila
# 2020 Pierre Gruet
# Author: Pierre Gruet <pgt@debian.org>
set -e
SOURCEDIR=$(pwd)
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
# Create a file with the first 100 digits of the square root of 2.
cat <<EOF > Rac2_100
1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641572
EOF
# Create the Java code that will run.
cat <<EOF > Test.java
import org.apfloat.Apfloat;
import org.apfloat.ApfloatMath;
public class Test
{
public static void main(String[] args)
{
Apfloat x = new Apfloat(2, 100);
System.out.println(ApfloatMath.sqrt(x));
}
}
EOF
#Building and running.
export CLASSPATH=".:/usr/share/java/apfloat.jar"
javac Test.java
java Test > outRac2
diff Rac2_100 outRac2
if [ $? -ne 0 ]; then
exit 1
fi
|