Tests: TODO js_return.t fail seen with older njs on some platforms.
diff --git a/js_return.t b/js_return.t index 725c881..bf3d7ee 100644 --- a/js_return.t +++ b/js_return.t
@@ -12,6 +12,8 @@ use Test::More; +use Config; + BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; @@ -41,6 +43,10 @@ listen 127.0.0.1:8080; server_name localhost; + location /njs { + js_content test_njs; + } + location / { js_content test_return; } @@ -50,8 +56,11 @@ EOF $t->write_file('test.js', <<EOF); + function test_njs(req, res) { + res.return(200, njs.version); + } + function test_return(req, res) { - njs.version; res.return(Number(req.args.c), req.args.t); } @@ -65,6 +74,13 @@ like(http_get('/?c=200&t=SEE-THIS'), qr/200 OK.*^SEE-THIS$/ms, 'return text'); like(http_get('/?c=301&t=path'), qr/ 301 .*Location: path/s, 'return redirect'); like(http_get('/?c=404'), qr/404 Not.*html/s, 'return error page'); + +TODO: { +my ($v) = http_get('/njs') =~ /^([.0-9]+)$/m; +local $TODO = 'not yet' unless $v ge '0.2.1' or $Config{archname} !~ /aarch64/; + like(http_get('/?c=inv'), qr/ 500 /, 'return invalid'); +} + ###############################################################################