1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::FailWarnings;
use JavaScript::QuickJS;
my $js = JavaScript::QuickJS->new()->std();
my $environ;
$js->set_globals(
env2perl => sub { $environ = shift },
);
my @env_kv = (
"on\xe9" => "tw\xf6",
);
my @env_kv_utf8 = @env_kv;
utf8::encode($_) for @env_kv_utf8;
{
local %ENV = @env_kv_utf8;
$js->eval( q/
import('std').then(std => env2perl(std.getenviron()));
/ );
$js->await();
}
TODO: {
local $TODO = 'Seems not to work on Windows' if $^O eq 'MSWin32';
is_deeply(
$environ,
{ @env_kv },
'imported `std` and called getenviron() as expected',
) or diag explain $environ;
}
done_testing;
1;
|