#!/bin/bash Fail() { echo "FATAL(demo/nodejs/demotest): $1" exit 1 } TestDemo() { echo "Testing Node.js demo: $1" node --trace-uncaught $* > test/$1${SUFFIX}.txt || Fail "Error running $1.js." diff {correct,test}/$1${SUFFIX}.txt || Fail "Incorrect output from $1.js." } rm -f test/*.txt mkdir -p test SUFFIX= TestDemo solar_time +38.88 -77.03 2023-02-12T17:00:00Z TestDemo equatorial 38.1256 -89.5544 215.7 23.5 2021-03-27T18:45:00Z TestDemo equator_of_date a 12 45 2021-07-06T00:00:00Z SUFFIX=_nz TestDemo camera -41.17 175.5 2023-03-24T06:30:00Z SUFFIX=_fl TestDemo camera +29 -81 2023-03-25T00:00:00Z SUFFIX=_ca TestDemo camera 51.05 -114.07 2023-03-24T02:07:31.000Z TestDemo moonphase 2019-06-15T09:15:32.987Z TestDemo positions +45.6 -90.7 2018-11-30T17:55:07.234Z TestDemo riseset +45.6 -90.7 2018-11-30T17:55:07.234Z TestDemo seasons 2019 TestDemo culminate +30 -90 2015-02-28T00:00Z TestDemo horizon +25.5 -85.3 2016-12-25T12:30:45Z TestDemo lunar_eclipse 1988-01-01 TestDemo triangulate 48.16042 24.49986 2019 18 7 48.27305 24.36401 662 83 12 TestDemo vernal_point 1900-01-01 2000-01-01 TestDemo moon_north_south 2023-08-22 2000-12-18 1970-05-15T12:30:47.123Z echo "Testing Node.js demo: gravity" for latitude in {0..90}; do node --trace-uncaught gravity ${latitude} 0 >> test/gravity.txt || Fail "Error running gravity.js." done diff {correct,test}/gravity.txt || Fail "Incorrect output from gravity.js." cd calendar || Fail "Cannot change to calendar directory." ./run || exit 1 cd .. echo "PASS: Node.js demos" exit 0