#!/usr/bin/perl # (C) Dmitry Volyntsev # (C) Nginx, Inc. # Tests for stream njs module, WebCrypto module. ############################################################################### use warnings; use strict; use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; use Test::Nginx; use Test::Nginx::Stream qw/ stream /; ############################################################################### select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/stream stream_return/) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% daemon off; events { } stream { %%TEST_GLOBALS_STREAM%% js_import test.js; js_set $test test.random_values_test; server { listen 127.0.0.1:8081; return $test; } } EOF $t->write_file('test.js', < a + count1(v), 0); let nbits = buf.length * 32; let mean = nbits / 2; let stdd = Math.sqrt(nbits / 4); return bits1 > (mean - 10 * stdd) && bits1 < (mean + 10 * stdd); } export default {random_values_test}; EOF $t->try_run('no stream js_var')->plan(1); ############################################################################### is(stream('127.0.0.1:' . port(8081))->io('###'), 'true', 'random values test'); ###############################################################################