! bn_unquoted_args_noremote.jnl
! 12/2015 -- a hack change to PPARSE_COMMAND to allow users to omit
! the quotation marks in the argument(s) of SET DATA, GO and DEFINE SYMBOL

! 2/2016 *sh* removed the GO/HELP tests

spawn "mkdir -p tmp"

! ****** SET DATA TESTS *****
! make test files
save/clobber/file="tmp/test1.nc" i[i=1:3] + 1
save/clobber/file="tmp/test2.nc" i[i=1:3] + 2
save/clobber/file="tmp/test3.nc" i[i=1:3] + 3
! generate absolute path
let dir = SPAWN("pwd")
define sym use_abs_path = `DIR+"/tmp/test1.nc"`
say ($use_abs_path)

use tmp/test1.nc
show data/brief
canc data/all

use "tmp/test1.nc"
show data/brief
canc data/all

use "tmp/test1.nc"
show data/brief
canc data/all

use tmp/test1.nc
show data/brief
canc data/all

use "($use_abs_path)"
show data/brief
canc data/all

use ($use_abs_path)
show data/brief
canc data/all

use tmp/test1.nc,tmp/test2.nc,tmp/test3.nc
show data/brief
canc data/all

use tmp/test1.nc,"tmp/test2.nc", tmp/test3.nc
show data/brief
canc data/all

! deliberate errors
! erroneous qualifier with no white space detected
set mode ignore
set data/erroneous tmp/test1.nc

! erroneous qualifier with white space detected
set data /erroneous tmp/test1.nc

! erroneous qualifier with comma treated as an invalid filename
set data /erroneous, tmp/test1.nc

can mode ignore

canc data/all


! ****** GO script tests *****
! make a dummy GO file for testing
spawn rm -f tmp/dummy.jnl
spawn echo "say hello" >tmp/dummy.jnl
spawn echo 'say $1"1-n/a"  $2"2-n/a"  $3"3-n/a"  $4"4-n/a" $5"5-n/a" $6"6-n/a" $7"7-n/a" $8"8-n/a"' > tmp/testMe.jnl

! generate absolute path
let dir = SPAWN("pwd")
define sym abs_path = `DIR+"/tmp/testMe.jnl"`
say ($abs_path)

go tmp/testMe.jnl

go "tmp/testMe.jnl"

go ($abs_path)

go "($abs_path)"

go tmp/testMe 5 hello "bye" "/quoted_path" /unquoted_path

go "tmp/testMe" 5 hello "bye" "/quoted_path" /unquoted_path

go ($abs_path) 5 hello "bye" "/quoted_path" /unquoted_path

go "($abs_path)" 5 hello "bye" "/quoted_path" /unquoted_path

! test GO/HELP
! 2/2016 - commented these tests out, tho they work fine.   GO/HELP
!          apparently runs asynchronously with the bench logging (why?)
!          This results in the placement of the GO/HELP output shifting in
!          the benchmark output log -- a hassle when comparing benchmarks
!go/help tmp/testMe
!go /help tmp/testMe
!go/help "tmp/testMe"
!go/help ($abs_path)
!go/help "($abs_path)"

! a few tests the slipped through the first time
GO tmp/testMe POLYGON/KEY/lev=20 xpts,ypts,sst,star
go "tmp/testMe.jnl" /home/users/tmap/ferret/linux/fer_dsets/data/coads_climatology.cdf
if 1 then let/quiet mytestvar = whatever
sh var mytestvar


set mode ignore
go/garbage tmp/testMe
go/garbage "tmp/testMe"
go/garbage ($abs_path)
go/garbage "($abs_path)"
set mode/last ignore


