# Process with autom4te to create an -*- Autotest -*- test suite.

AT_INIT([dmr-test])

AT_ARG_OPTION_ARG([generate_parse],
    [--generate_parse=arg   Build the baseline file for parser test 'arg'],
    [echo "./dmr-test -x -p $at_arg_generate_parse > $at_arg_generate_parse.baseline 2>&1";
     ./dmr-test -x -p $at_arg_generate_parse > $at_arg_generate_parse.baseline 2>&1;
     echo "Built baseline for $at_arg_generate_parse";
     exit],[])

AT_ARG_OPTION_ARG([generate_trans],
    [--generate_trans=arg  Build the baseline file for round trip transmission test 'arg'],
    [echo "./dmr-test -x -t $at_arg_generate_trans > $at_arg_generate_trans.trans_base 2>&1";
     ./dmr-test -x -t $at_arg_generate_trans > $at_arg_generate_trans.trans_base 2>&1;
     echo "Built baseline for $at_arg_generate_trans";
     exit],[])

AT_ARG_OPTION_ARG([generate_trans_ce],
    [--generate_trans_ce=dataset,ce,ext  Build the baseline (ext) file for round trip transmission test 'arg' with 'ce'],
    [data=`echo $at_arg_generate_trans_ce | sed 's@\(.*\),\(.*\),\(.*\)@\1@g'`
     ce=`echo $at_arg_generate_trans_ce | sed 's@\(.*\),\(.*\),\(.*\)@\2@g'`
     code=`echo $at_arg_generate_trans_ce | sed 's@\(.*\),\(.*\),\(.*\)@\3@g'`
     echo "./dmr-test -x -t $data -c $ce > $data.$code.trans_base 2>&1";
     ./dmr-test -x -t $data -c "$ce" > $data.$code.trans_base 2>&1;
     echo "Built baseline for $at_arg_generate_trans_ce";
     exit],[])

# There is no easy way to write a --generate... option for the function expression
# tests. Better to do it by hand... Use ... .num.func_base as the extension for the
# baselines.
 
# Usage DMR_PARSE $1 <test_input> $2 <pass/xfail>
# The baseline is assumed to be $1.baseline
m4_define([DMR_PARSE], [

    AT_SETUP([parse $1])
    AT_KEYWORDS([parse])
    
    input=$abs_srcdir/$1
    baseline=$input.baseline
    
    AT_CHECK([$abs_builddir/dmr-test -x -p $input || true], [], [stdout], [stderr])
    AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
    AT_XFAIL_IF([test "$2" = "xfail"])
    
    AT_CLEANUP
])

# Usage DMR_TRANS $1 <test_input> $2 <pass/xfail>
# This code tests the values printed when the received document is decoded.
m4_define([DMR_TRANS], [
    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
    AT_SETUP([trans/receive $1])
    AT_KEYWORDS([trans])
    
    input=$abs_srcdir/$1
    baseline=$input.trans_base

    AT_CHECK([$abs_builddir/dmr-test -x -t $input || true], [], [stdout], [stderr])
    AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
    
    AT_XFAIL_IF([test "$2" = "xfail"])
    AT_CLEANUP
])

# Usage DMR_TRANS_CE <test_input> <ce> <baseline> <pass/xfail>
# This code tests the values printed when the received document is decoded.
m4_define([DMR_TRANS_CE], [
    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
    # after applying a constraint expression to the source DMR.
    AT_SETUP([trans/receive $1 $2])
    AT_KEYWORDS([trans])
    
    input=$abs_srcdir/$1
    baseline=$abs_srcdir/$3
    
    # echo "baseline: $baseline"

    AT_CHECK([$abs_builddir/dmr-test -x -t $input -c "$2" || true], [], [stdout], [stderr])
    AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
    
    AT_XFAIL_IF([test "X$4" = "Xxfail"])
    AT_CLEANUP
])

# Usage DMR_TRANS_FUNC_CE <test_input> <func expr> <ce> <baseline> <pass/xfail>
# This code tests the values printed when the received document is decoded.
m4_define([DMR_TRANS_FUNC_CE], [
    # Test transmitting data (i.e., writing the Data DMR to a file and then decoding it)
    # after applying a function and constraint expression to the source DMR. If either
    # the function or constraint are empty strings, they will be ignored.
    AT_SETUP([trans/receive $1 $2 $3])
    AT_KEYWORDS([trans])
    
    input=$abs_srcdir/$1
    fe="$2"
    ce="$3"
    baseline=$abs_srcdir/$4
    # This doesn't work for some reason. jhrg 3/13/14 expect="$5"
    
    AT_CHECK([$abs_builddir/dmr-test -x -t $input -f "$fe" -c "$ce" || true], [], [stdout], [stderr])
    AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
    
    AT_XFAIL_IF([test "X$5" = "Xxfail"])

    AT_CLEANUP
])

# Usage DMR_INTERN $1 <test_input> $2 <pass/xfail>
# This code tests the values printed when the received document is decoded.
m4_define([DMR_INTERN], [
    # Test reading/interning data (i.e., using the read() methods to load up objects with
    # values without running them through serialize/deserialize)
    AT_SETUP([intern data $1])
    AT_KEYWORDS([intern])
    
    input=$abs_srcdir/$1
    baseline=$input.trans_base

    AT_CHECK([$abs_builddir/dmr-test -x -i $input || true], [], [stdout], [stderr])
    AT_CHECK([diff -b -B $baseline stdout || diff -b -B $baseline stderr], [], [ignore],[],[])
    
    AT_XFAIL_IF([test "$2" = "xfail"])
    AT_CLEANUP
])

DMR_PARSE([dmr-testsuite/test_simple_1.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_2.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_3.xml], [pass])

DMR_PARSE([dmr-testsuite/test_simple_3_error_1.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_3_error_2.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_3_error_3.xml], [pass])

DMR_PARSE([dmr-testsuite/test_simple_4.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_5.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_6.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_7.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_8.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_9.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_9.1.xml], [pass])
DMR_PARSE([dmr-testsuite/test_simple_10.xml], [pass])

DMR_PARSE([dmr-testsuite/test_array_1.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_2.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_3.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_4.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_5.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_6.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_7.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_8.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_10.xml], [pass])
DMR_PARSE([dmr-testsuite/test_array_11.xml], [pass])

# Transmit: Test building and then decoding the response

DMR_TRANS([dmr-testsuite/test_simple_1.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_2.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_3.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_4.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_5.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_6.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_7.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_8.xml], [xfail])
DMR_TRANS([dmr-testsuite/test_simple_9.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_9.1.xml], [pass])
DMR_TRANS([dmr-testsuite/test_simple_10.xml], [pass])

DMR_TRANS([dmr-testsuite/test_array_1.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_2.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_3.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_4.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_5.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_6.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_7.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_8.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_10.xml], [pass])
DMR_TRANS([dmr-testsuite/test_array_11.xml], [pass])

DMR_INTERN([dmr-testsuite/test_simple_1.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_2.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_3.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_4.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_5.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_6.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_7.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_8.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_9.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_9.1.xml], [pass])
DMR_INTERN([dmr-testsuite/test_simple_10.xml], [pass])

DMR_INTERN([dmr-testsuite/test_array_1.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_2.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_3.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_4.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_5.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_6.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_7.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_8.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_10.xml], [pass])
DMR_INTERN([dmr-testsuite/test_array_11.xml], [pass])

# Test various factes of the CE parser and evaluation engine

DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [a], [dmr-testsuite/test_array_4.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [a[[]][[]] ], [dmr-testsuite/test_array_4.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [/row=[[0:1]];/col=[[3]];a],  [dmr-testsuite/test_array_4.xml.3.trans_base], [pass])
    
DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [/row=[[0:1]];/col=[[3]];a[[]][[]] ],  [dmr-testsuite/test_array_4.xml.4.trans_base], [pass])
    
DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [/row=[[0:1]];/col=[[3]];a[[]][[]];b[[0]][[]];c[[0:]][[0:]] ],  [dmr-testsuite/test_array_4.xml.5.trans_base], [pass])
    
DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [x[[]][[]] ], [dmr-testsuite/test_array_4.xml.6.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [/row=[[0:1]];x[[]][[]] ], [dmr-testsuite/test_array_4.xml.7.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_4.xml], [c[[2:]][[2:]] ], [dmr-testsuite/test_array_4.xml.8.trans_base], [pass])
    
DMR_TRANS_CE([dmr-testsuite/test_simple_6.xml], [s], [dmr-testsuite/test_simple_6.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.xml], [s.i1], [dmr-testsuite/test_simple_6.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.xml], [s.s], [dmr-testsuite/test_simple_6.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.1.xml], [s.inner.i2], [dmr-testsuite/test_simple_6.1.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_simple_6.xml], [s{i1}], [dmr-testsuite/test_simple_6.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.xml], [s{s}], [dmr-testsuite/test_simple_6.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.1.xml], [s{inner.i2}], [dmr-testsuite/test_simple_6.1.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_6.1.xml], [s{inner{i2}}], [dmr-testsuite/test_simple_6.1.xml.1.trans_base], [pass])

# test_array_6 holds a 2D array of Structure
DMR_TRANS_CE([dmr-testsuite/test_array_6.xml], [a], [dmr-testsuite/test_array_6.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.xml], [a[[]][[]] ], [dmr-testsuite/test_array_6.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.xml], [/row=[[0:1]];a[[]][[]] ], [dmr-testsuite/test_array_6.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.xml], [/row=[[0:1]];a[[]][[1:2]] ], [dmr-testsuite/test_array_6.xml.3.trans_base], [pass])

# test_array holds a Structure that has a 2D array for a field
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a], [dmr-testsuite/test_array_6.2.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a{i;j}], [dmr-testsuite/test_array_6.2.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a.i], [dmr-testsuite/test_array_6.2.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a{i}], [dmr-testsuite/test_array_6.2.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a.i[[0]][[1:2]] ], [dmr-testsuite/test_array_6.2.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a{i[[0]][[1:2]]} ], [dmr-testsuite/test_array_6.2.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [/row=[[0:1]];a.i[[]][[1:2]] ], [dmr-testsuite/test_array_6.2.xml.4.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [/row=[[0:1]];a{i[[]][[1:2]]} ], [dmr-testsuite/test_array_6.2.xml.4.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_6.2.xml], [a.j], [dmr-testsuite/test_array_6.2.xml.5.trans_base], [pass])

# test_array_6.1 is an array of Structure that holds an array and a scalar
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [a], [dmr-testsuite/test_array_6.1.xml.1.trans_base], [pass])

# slice the structure but not the field
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [/row=[[1:2]];a[[]][[0]] ], [dmr-testsuite/test_array_6.1.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [/row=[[1:2]];a[[]][[0]]{i;j} ], [dmr-testsuite/test_array_6.1.xml.2.trans_base], [pass])
# Do we really need the FQN?
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [row=[[1:2]];a[[]][[0]]{i;j} ], [dmr-testsuite/test_array_6.1.xml.2.trans_base], [pass])

# slice the field but not the structure
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [a{i[[1:2]][[1:3]];j} ], [dmr-testsuite/test_array_6.1.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [a[[]][[]]{i[[1:2]][[1:3]];j} ], [dmr-testsuite/test_array_6.1.xml.3.trans_base], [pass])

# slice both the structure and the array it contains using both the shared dim and 
# a local slice for each
DMR_TRANS_CE([dmr-testsuite/test_array_6.1.xml], [/row=[[1]];a[[]][[0]]{i[[]][[0:1]]} ], [dmr-testsuite/test_array_6.1.xml.4.trans_base], [pass])

# Test sequences and arrays of sequences
DMR_TRANS_CE([dmr-testsuite/test_simple_7.xml], [s], [dmr-testsuite/test_simple_7.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_7.xml], [s{i1;s}], [dmr-testsuite/test_simple_7.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_simple_7.xml], [s.i1], [dmr-testsuite/test_simple_7.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_simple_7.xml], [s{i1}], [dmr-testsuite/test_simple_7.xml.2.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_simple_8.xml], [outer], [dmr-testsuite/test_simple_8.xml.1.trans_base], [xfail])
DMR_TRANS_CE([dmr-testsuite/test_simple_8.xml], [outer.s.s], [dmr-testsuite/test_simple_8.xml.2.trans_base], [xfail])
DMR_TRANS_CE([dmr-testsuite/test_simple_8.xml], [outer{s{s}}], [dmr-testsuite/test_simple_8.xml.2.trans_base], [xfail])

DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s], [dmr-testsuite/test_array_7.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s{i1;s}], [dmr-testsuite/test_array_7.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s.i1], [dmr-testsuite/test_array_7.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s{i1}], [dmr-testsuite/test_array_7.xml.2.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s[[1]] ], [dmr-testsuite/test_array_7.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s[[1]]{i1;s}], [dmr-testsuite/test_array_7.xml.3.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.xml], [s[[1]]{i1}], [dmr-testsuite/test_array_7.xml.4.trans_base], [pass])

# test_array_8 has a 2D Sequence that uses a shared dim
DMR_TRANS_CE([dmr-testsuite/test_array_8.xml], [/col=[[1:2]];s[[1]][[]]{i1}], [dmr-testsuite/test_array_8.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_8.xml], [col=[[1:2]];s[[1]][[]]{i1}], [dmr-testsuite/test_array_8.xml.1.trans_base], [pass])

# test_array_7.1 holds a sequence that has an array for one of its fields
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [], [dmr-testsuite/test_array_7.1.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s], [dmr-testsuite/test_array_7.1.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s.i1], [dmr-testsuite/test_array_7.1.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s.i1[[]][[]] ], [dmr-testsuite/test_array_7.1.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s{i1}], [dmr-testsuite/test_array_7.1.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s{i1[[]][[]]} ], [dmr-testsuite/test_array_7.1.xml.2.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s.i1[[0]][[0]] ], [dmr-testsuite/test_array_7.1.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s{i1[[0]][[0]]} ], [dmr-testsuite/test_array_7.1.xml.3.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [s.i1[[0:2]][[1:2]] ], [dmr-testsuite/test_array_7.1.xml.4.trans_base], [pass])

# Should this CE be supported? jhrg 12/23/13
# DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]] ], [dmr-testsuite/test_array_7.1.xml.5.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s ], [dmr-testsuite/test_array_7.1.xml.5.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s.i1 ], [dmr-testsuite/test_array_7.1.xml.6.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s.i1[[]][[]] ], [dmr-testsuite/test_array_7.1.xml.6.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s{i1} ], [dmr-testsuite/test_array_7.1.xml.6.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.1.xml], [/row=[[2:3]];/col=[[2:3]];s{i1[[]][[]]} ], [dmr-testsuite/test_array_7.1.xml.6.trans_base], [pass])

# test_array_7.2 is a sequence array that holds an array as one of its fields
DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1}], [dmr-testsuite/test_array_7.2.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1[[]][[]]}], [dmr-testsuite/test_array_7.2.xml.1.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s{i1[[]][[]]}], [dmr-testsuite/test_array_7.2.xml.1.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[]]{i1[[0]][[]]}], [dmr-testsuite/test_array_7.2.xml.2.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s{i1[[0]][[]]}], [dmr-testsuite/test_array_7.2.xml.2.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1}], [dmr-testsuite/test_array_7.2.xml.3.trans_base], [pass])
DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1[[]][[]]}], [dmr-testsuite/test_array_7.2.xml.3.trans_base], [pass])

DMR_TRANS_CE([dmr-testsuite/test_array_7.2.xml], [/col=[[1:2]];s[[0]]{i1[[0]][[]]}], [dmr-testsuite/test_array_7.2.xml.4.trans_base], [pass])

# Test the function parser and evaluator. The function 'scale' is defined 
# for both DAP2 and DAP4 in D4TestFunction.cc/h
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,1)], [], [dmr-testsuite/test_array_1.xml.1.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,10)], [], [dmr-testsuite/test_array_1.xml.2.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,-10)], [], [dmr-testsuite/test_array_1.xml.3.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,0.001)], [], [dmr-testsuite/test_array_1.xml.4.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,-0.001)], [], [dmr-testsuite/test_array_1.xml.5.func_base], [pass])

# Test the largest signed int64 value (it will be stored in a D4RValue that 
# holds a Int64 variable).
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,0x7fffffffffffffff)], [], [dmr-testsuite/test_array_1.xml.6.func_base], [pass])
# This only fits in a unsigned long long (DAP4's UInt64)
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_1.xml], [scale(x,0x8fffffffffffffff)], [], [dmr-testsuite/test_array_1.xml.7.func_base], [pass])

# test_array_5 has 64 bit ints in c and d; a and b are Int8 and UInt8 types
# all of these test arrays that use named dimensions
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_5.xml], [scale(a,0.001)], [], [dmr-testsuite/test_array_5.xml.1.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_5.xml], [scale(b,0.001)], [], [dmr-testsuite/test_array_5.xml.2.func_base], [pass])

DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_5.xml], [scale(c,0.001)], [], [dmr-testsuite/test_array_5.xml.3.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/test_array_5.xml], [scale(d,0.001)], [], [dmr-testsuite/test_array_5.xml.4.func_base], [pass])

# Use the vol_1_ce_* datasets for tests

# Test using variables for source values and functional composition
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(u,10)], [], [dmr-testsuite/vol_1_ce_1.xml.1.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(u,v)], [], [dmr-testsuite/vol_1_ce_1.xml.2.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(scale(u,10),0.01)], [], [dmr-testsuite/vol_1_ce_1.xml.3.func_base], [pass])

# Test name parsing for Structure members
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(Point.x,10)], [], [dmr-testsuite/vol_1_ce_1.xml.4.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(Point.x,Point.y)], [], [dmr-testsuite/vol_1_ce_1.xml.5.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(scale(Point.x,10),0.01)], [], [dmr-testsuite/vol_1_ce_1.xml.6.func_base], [pass])

# Test the 'array constant' special form (we need a dataset only because the parser needs a DMR to run)
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Byte(20:1,2,3,4),10)], [], [dmr-testsuite/vol_1_ce_1.xml.7.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Int8(20:10,11,12,-9),10)], [], [dmr-testsuite/vol_1_ce_1.xml.8.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$UInt16(20:1,2,3,4),10)], [], [dmr-testsuite/vol_1_ce_1.xml.9.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Int16(20:1,2,3,-4),10)], [], [dmr-testsuite/vol_1_ce_1.xml.10.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$UInt32(20:1,2,3,4),10)], [], [dmr-testsuite/vol_1_ce_1.xml.11.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Int32(20:1,2,3,-4),10)], [], [dmr-testsuite/vol_1_ce_1.xml.12.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$UInt64(20:1,2,3,0xffffffffffffffff),1)], [], [dmr-testsuite/vol_1_ce_1.xml.13.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Int64(20:1,2,3,0x7fffffffffffffff),1)], [], [dmr-testsuite/vol_1_ce_1.xml.14.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Float32(20:1,2,3,4.55),10)], [], [dmr-testsuite/vol_1_ce_1.xml.15.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_1.xml], [scale(\$Float64(20:1,2,3,4.55),10)], [], [dmr-testsuite/vol_1_ce_1.xml.16.func_base], [pass])

# Test a sequence of function calls and the application of a Constraint to 
# a function result
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_10.xml], [scale(lat,10)], [], [dmr-testsuite/vol_1_ce_10.xml.1.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_10.xml], [scale(lat,10);scale(lon,10)], [], [dmr-testsuite/vol_1_ce_10.xml.2.func_base], [pass])
DMR_TRANS_FUNC_CE([dmr-testsuite/vol_1_ce_10.xml], [scale(lat,10);scale(lon,10)], [lat[[10:11]][[10:11]];lon[[10:11]][[10:11]]], [dmr-testsuite/vol_1_ce_10.xml.3.func_base], [pass])



