#!/bin/sh

exec 2>&1

set -e

test_executables_eus0() {
    # if eusrt.l is not exists, it fails before print *user*
    name=$( eus0 "(progn (print *user*) (unix::exit))" )
    assertNotEquals "" "$name"
}

test_executables_eus1() {
    # if eusrt.l is not exists, it fails before print *user*
    name=$( eus1 "(progn (print *user*) (unix::exit))" )
    assertNotEquals "" "$name"
}

test_executables_eus2() {
    # if eusrt.l is not exists, it fails before print *user*
    name=$( eus2 "(progn (print *user*) (unix::exit))" )
    assertNotEquals "" "$name"
}

test_executables_eusg() {
    # If libeusgeo.so not exists, calling (make-cube) fails.
    name=$( eusg "(progn (print (make-cube 10 10 10)) (unix::exit))" )
    assertNotEquals "" "$name"
}

test_executables_eusx() {
    # if eusx faile to load libeusx.so, it fails to initialize x::*display*
    name=$( eusx "(progn (print (print x::*display*)) (unix::exit))" )
    assertNotEquals "" "$name"

    # if eusx faile to load image functions from libeusgeo.so, it fails to instantiate color-image
    name=$( eusx "(progn (print (instance color-image :init 100 100)) (unix::exit))" )
    assertNotEquals "" "$name"
}

test_executables_eusgl() {
    # if eusgl faile to load libeusgl.so, it fails to initialize gl::*perspective-near*
    name=$( eusgl "(progn (gl::glbegin gl::gl_polygon)(gl::glnormal3fv #f(1 1 1))(gl::glend) (print gl::*perspective-near*) (unix::exit))" )
    assertNotEquals "" "$name"

    # if eusgl failed to load opengl/src/util.c, it fails to call gl::glrotatefv
    name=$( eusgl "(progn (gl::glrotatefv #f(1 1 1 1)) (print gl::*perspective-near*) (unix::exit))" )
    assertNotEquals "" "$name"
}

. shunit2
