Skip to content

Commit

Permalink
Add test to check substitution of ctor nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmmr committed Dec 12, 2022
1 parent 72ea44b commit 46d781e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/Baseline/hilti.expressions.ctor-replacement/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[debug/ast-final] # [HILTI] Test: Final AST (round 1)
[debug/ast-final] - Module %4 (ctor-replacement.hlt:6:1-12:2) [@m:XXX]
[debug/ast-final] | Test -> declaration::Module %6 <id="Test"> [canon-id: Test] [@d:XXX] ([@d:XXX])
[debug/ast-final] | x -> declaration::GlobalVariable %1 <linkage="private"> [canon-id: Test::x] [@d:XXX] ([@d:XXX])
[debug/ast-final] | y -> declaration::GlobalVariable %2 <linkage="private"> [canon-id: Test::y] [@d:XXX] ([@d:XXX])
[debug/ast-final] | z -> declaration::GlobalVariable %3 <linkage="private"> [canon-id: Test::z] [@d:XXX] ([@d:XXX])
[debug/ast-final] - ID <name="Test"> (ctor-replacement.hlt:6:8) [@i:XXX]
[debug/ast-final] - statement::Block (ctor-replacement.hlt:6:1-12:2) [@s:XXX]
[debug/ast-final] - declaration::GlobalVariable %1 <linkage="private"> (ctor-replacement.hlt:6:14-8:22) [canon-id: Test::x] [@d:XXX]
[debug/ast-final] - ID <name="x"> (ctor-replacement.hlt:8:8) [@i:XXX]
[debug/ast-final] - node::None (ctor-replacement.hlt:6:14-8:22) [@n:XXX]
[debug/ast-final] - expression::Ctor (ctor-replacement.hlt:8:12) (const) (resolved) [@e:XXX]
[debug/ast-final] - ctor::SignedInteger <value="-1" width="32"> (ctor-replacement.hlt:8:12) [@c:XXX]
[debug/ast-final] - type::SignedInteger <width="32"> (const) (resolved) [@t:XXX]
[debug/ast-final] - declaration::GlobalVariable %2 <linkage="private"> (ctor-replacement.hlt:8:22-9:22) [canon-id: Test::y] [@d:XXX]
[debug/ast-final] - ID <name="y"> (ctor-replacement.hlt:9:8) [@i:XXX]
[debug/ast-final] - node::None (ctor-replacement.hlt:6:14-8:22) [@n:XXX]
[debug/ast-final] - expression::Ctor (ctor-replacement.hlt:9:12) (const) (resolved) [@e:XXX]
[debug/ast-final] - ctor::UnsignedInteger <value="1" width="32"> (ctor-replacement.hlt:9:12) [@c:XXX]
[debug/ast-final] - type::UnsignedInteger <width="32"> (const) (resolved) [@t:XXX]
[debug/ast-final] - declaration::GlobalVariable %3 <linkage="private"> (ctor-replacement.hlt:9:22-10:15) [canon-id: Test::z] [@d:XXX]
[debug/ast-final] - ID <name="z"> (ctor-replacement.hlt:10:8) [@i:XXX]
[debug/ast-final] - node::None (ctor-replacement.hlt:6:14-8:22) [@n:XXX]
[debug/ast-final] - expression::Ctor (ctor-replacement.hlt:10:12) (const) (resolved) [@e:XXX]
[debug/ast-final] - ctor::SignedInteger <value="-1" width="64"> (ctor-replacement.hlt:10:12) [@c:XXX]
[debug/ast-final] - type::SignedInteger <width="64"> (ctor-replacement.hlt:10:12) (const) (resolved) [@t:XXX]
module Test {

global int<32> x = int32(-1);
global uint<32> y = uint32(1);
global int<64> z = -1;

}
12 changes: 12 additions & 0 deletions tests/hilti/expressions/ctor-replacement.hlt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @TEST-EXEC: hiltic -p -D ast-final %INPUT >output 2>&1
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Check that the constant folder replaces constant expressions with corresponding ctor nodes, and that the printer round-trips the result.

module Test {

global x = int32(-1);
global y = uint32(1);
global z = -1; # int64

}

0 comments on commit 46d781e

Please sign in to comment.