Created
May 2, 2012 13:56
-
-
Save yuki-kimoto/2576690 to your computer and use it in GitHub Desktop.
Perlee Script test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::More 'no_plan'; | |
use strict; | |
use warnings; | |
use PerleeScript; | |
my $ps = PerleeScript->new; | |
# my to var | |
is($ps->source(q/my $title = 'Perl';/)->to_javascript, q/var $title = 'Perl';/); | |
# Number nuderline is removed | |
is($ps->source(q/my $price = 3_000;/)->to_javascript, q/var $price = 3000;/); | |
# Unless to if not | |
is($ps->source(q/unless ($done) { 1 }/)->to_javascript, | |
q/if (!($done)) { 1 }/); | |
is($ps->source(q/unless (done()) { 1 }/)->to_javascript, | |
q/if (!(done())) { 1 }/); | |
is($ps->source(q/unless (done()->title()) { 1 }/)->to_javascript, | |
q/if (!(done().title())) { 1 }/); | |
# String | |
is($ps->source(q/"300"/)->to_javascript, q/"300"/); | |
# Allow to dot | |
is($ps->source(q/$book->author/)->to_javascript, q/$book.author/); | |
# String join | |
is($ps->source(q/$foo . $bar/)->to_javascript, q/$foo + '' + $bar/); | |
# Number operation | |
is($ps->source(q/$foo + $bar/)->to_javascript, q/$foo * 1 + +$bar/); | |
is($ps->source(q/$foo - $bar/)->to_javascript, q/$foo * 1 - +$bar/); | |
is($ps->source(q/$foo * $bar/)->to_javascript, q/$foo * 1 * +$bar/); | |
is($ps->source(q{$foo / $bar})->to_javascript, q{$foo * 1 / +$bar}); | |
is($ps->source(q/$foo % $bar/)->to_javascript, q/$foo * 1 % +$bar/); | |
# Comment | |
is($ps->source(q/# foo/)->to_javascript, q{// foo}); | |
# elsif to else if | |
is($ps->source(q/elsif ($done) { 1 }/)->to_javascript, q/else if ($done) { 1 }/); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment