Skip to content

Commit

Permalink
Future tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cheako committed Jul 14, 2017
1 parent e01e287 commit 1e0acca
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tx/assignment_operator.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use Test::More tests => 2;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

$value_ref = $grammar->parse( \(<<'EOI') );
a=42 * 1 + 7
EOI

is_deeply $value_ref, \[ ['assignment', 'a', '42 * 1 + 7' ] ];
39 changes: 39 additions & 0 deletions tx/comment.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use Test::More tests => 5;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

$value_ref = $grammar->parse( \(<<'EOI') );
42 * 1 + 7 # Add one and seven, multiply by fourty-two
EOI

is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ];

$value_ref = $grammar->parse( \(<<'EOI') );
42 * 1 + 7
# Add one and seven, multiply by fourty-two
EOI

is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ];

$value_ref = $grammar->parse( \(<<'EOI') );
42 * 1 + 7 # Add one and seven, multiply by fourty-two
EOI

is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ];

$value_ref = $grammar->parse( \(<<'EOI') );
# Add one and seven, multiply by fourty-two
42 * 1 + 7
EOI

is_deeply $value_ref, \[ ['comment', ' Add one and seven, multiply by fourty-two'], 42 * 1 + 7 ];

$value_ref = $grammar->parse( \(<<'EOI') );
# Add one and seven, multiply by fourty-two
42 * 1 + 7
EOI

is_deeply $value_ref, \[ ['comment', ' Add one and seven, multiply by fourty-two'], 42 * 1 + 7 ];
15 changes: 15 additions & 0 deletions tx/end_of_script.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use Test::More tests => 1;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

my $input = <<'EOI';
42 * 1 + 7
42 * 1 + 7
EOI
chomp $input;
$value_ref = $grammar->parse( \$input );

is_deeply $value_ref, \[ 42 * 1 + 7, 42 * 1 + 7 ];
18 changes: 18 additions & 0 deletions tx/hex_magic.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use Test::More tests => 1;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

# This script prints "Hello World.\n"
$value_ref = $grammar->parse( \(<<'EOI') );
echo ${a:+
Hello
World.}
EOI

# Returns some magic foo I don't even know how to describe it.
is_deeply $value_ref, \[ undef ];
18 changes: 18 additions & 0 deletions tx/if_then.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use Test::More tests => 2;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

$value_ref = $grammar->parse( \(<<'EOI') );
if :; than :; fi
EOI

is_deeply $value_ref, \[ [ 'if', [ 'command', ':' ], [ 'command', ':' ], undef ];

$value_ref = $grammar->parse( \(<<'EOI') );
if :; than :; else :; fi
EOI

is_deeply $value_ref, \[ [ 'if', [ 'command', ':' ], [ 'command', ':' ], [ 'command', ':' ] ];
21 changes: 21 additions & 0 deletions tx/shabang.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use Test::More tests => 2;

use MarpaX::Languages::Bash::AST;
my $grammar = MarpaX::Languages::Bash::AST->new();

my $value_ref;

$value_ref = $grammar->parse( \(<<'EOI') );
#!/usr/bin/env bc
42 * 1 + 7
EOI

is_deeply $value_ref, \[ ['shabang', '/usr/bin/env bc'], 42 * 1 + 7 ];

$value_ref = $grammar->parse( \(<<'EOI') );
#!/usr/bin/env bc
42 * 1 + 7
42 * 1 + 7
EOI

is_deeply $value_ref, \[ ['shabang', '/usr/bin/env bc'], 42 * 1 + 7, 42 * 1 + 7 ];

0 comments on commit 1e0acca

Please sign in to comment.