Skip to content

Commit

Permalink
RakuAST: adapt tests/deparsing to new reality
Browse files Browse the repository at this point in the history
with regards to constant initializers
  • Loading branch information
lizmat committed Mar 18, 2023
1 parent be633ca commit c843b6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/core.c/RakuAST/Deparse.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -1957,8 +1957,7 @@ class RakuAST::Deparse {
if $ast.traits -> @traits {
@parts.push(self.deparse($_)) for @traits;
}
@parts.push('=');
@parts.push(self.deparse($ast.initializer));
@parts.push(self.deparse($ast.initializer).trim-leading);

@parts.join(' ');
}
Expand Down
12 changes: 9 additions & 3 deletions t/12-rakuast/var.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,9 @@ subtest 'Lexical constant' => {
ast RakuAST::Statement::Expression.new(
expression => RakuAST::VarDeclaration::Constant.new(
name => "foo",
initializer => RakuAST::StrLiteral.new("bar")
initializer => RakuAST::Initializer::Assign.new(
RakuAST::StrLiteral.new("bar")
)
)
);
is-deeply $deparsed, 'constant foo = "bar"', 'deparse';
Expand All @@ -1080,7 +1082,9 @@ subtest 'Lexical my constant' => {
expression => RakuAST::VarDeclaration::Constant.new(
scope => "my",
name => "foo",
initializer => RakuAST::StrLiteral.new("bar")
initializer => RakuAST::Initializer::Assign.new(
RakuAST::StrLiteral.new("bar")
)
)
);
is-deeply $deparsed, 'my constant foo = "bar"', 'deparse';
Expand All @@ -1096,7 +1100,9 @@ subtest 'Lexical my constant with expression' => {
expression => RakuAST::VarDeclaration::Constant.new(
scope => "my",
name => "foo",
initializer => RakuAST::Term::Named.new("now")
initializer => RakuAST::Initializer::Assign.new(
RakuAST::Term::Named.new("now")
)
)
);
is-deeply $deparsed, 'my constant foo = now', 'deparse';
Expand Down

0 comments on commit c843b6f

Please sign in to comment.