Skip Menu |
 

This queue is for tickets about the JavaScript CPAN distribution.

Report information
The Basics
Id: 69856
Status: new
Priority: 0/
Queue: JavaScript

People
Owner: Nobody in particular
Requestors: dan [...] butterfields.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.16
Fixed in: (no value)



Subject: One time Context->compile with repeated Script->exec does not work
Download (untitled) / with headers
text/plain 1.2k
I'm trying to do a compile once / exec repeatedly pattern as described in JavaScript::Context->compile documentation. The first exec execution works, but subsequent exec executions return garbage or abort. I have attached a simple test file showing this. On my system it displays this output: Javascript version: 'JavaScript-C 1.7.0 2007-10-03' First, with a single compile and reused script object: 0) Successful result of JavaScript = 'Hello world!' 1) Successful result of JavaScript = '' 2) Successful result of JavaScript = '' 3) Successful result of JavaScript = '' 4) Successful result of JavaScript = '' Now, compiling every time for a new script object: 0) Successful result of JavaScript = 'Hello world!' 1) Successful result of JavaScript = 'Hello world!' 2) Successful result of JavaScript = 'Hello world!' 3) Successful result of JavaScript = 'Hello world!' 4) Successful result of JavaScript = 'Hello world!' I should get a "Hello world!" in every result, but when I try to reuse the script object in this case, I get nothing. I am running Debian 2.6.32-5-amd64 with Perl v5.10.1 (*) built for x86_64-linux-gnu-thread-multi. You can see the SpiderMonkey version is 1.7. Maybe I should use a different version of SpiderMonkey? Thanks for a great module!
Subject: test_javascript.pl
Download test_javascript.pl
text/x-perl 701b
#!/usr/bin/env perl use JavaScript; print "Javascript version: '" . JavaScript->get_engine_version . "'\n"; my $rt = JavaScript::Runtime->new(); my $cx = $rt->create_context(); my $compiled_script = $cx->compile('x = "Hello world!";'); if ($@) { die "JavaScript error: $@"; } print "First, with a single compile and reused script object:\n"; for (my $i=0; $i<5; $i++) { print "$i) Successful result of JavaScript = '" . $compiled_script->exec . "'\n"; } print "Now, compiling every time for a new script object:\n"; for (my $i=0; $i<5; $i++) { my $compiled_script = $cx->compile('x = "Hello world!";'); print "$i) Successful result of JavaScript = '" . $compiled_script->exec . "'\n"; }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.