Skip to content

Commit

Permalink
loop arg tracing test added
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturGogiyan committed Mar 27, 2022
1 parent 89092cd commit 3bec4b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/NITTA/LuaFrontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ data LuaAlgBuilder x = LuaAlgBuilder
algVarCounters :: HM.HashMap T.Text Int
, -- | A table lists all uses of a particular LuaValueInstance.
algVars :: HM.HashMap LuaValueInstance [T.Text]
, -- | A table correlating the ordinal number of an argument with a variable storing its value and startup value of this variable.
, -- | Map argument index to the variable name and initial value (in text).
algStartupArgs :: HM.HashMap Int (T.Text, T.Text)
, -- | A table correlating constant with LuaValueInstance which store this constant.
algConstants :: HM.HashMap T.Text LuaValueInstance
Expand Down Expand Up @@ -397,7 +397,10 @@ lua2functions src =
where
getAllTraceFuncs algBuilder =
let traceFuncs = algTraceFuncs algBuilder
startupArgNames = map (\(_, (x, _)) -> x) $ HM.toList $ algStartupArgs algBuilder
startupArgNames =
map
(\(_idx, (varName, _initValue)) -> varName)
$ HM.toList $ algStartupArgs algBuilder
in map (\name -> ([name <> "^0"], defaultFmt)) startupArgNames <> traceFuncs

getFrTrace traceFuncs = [TraceVar fmt var | (vars, fmt) <- traceFuncs, var <- vars]
Expand Down
18 changes: 18 additions & 0 deletions test/NITTA/LuaFrontend/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,24 @@ test_complex_examples =

test_trace_features =
[ traceLuaSimulationTestCase
pInt
"loop argument tracing"
[__i|
function counter(i)
counter(i + 1)
end
counter(0)
|]
[__i|
| Cycle | i |
|:-------|:-------|
| 1 | 0.000 |
| 2 | 1.000 |
| 3 | 2.000 |
| 4 | 3.000 |
| 5 | 4.000 |\n
|]
, traceLuaSimulationTestCase
pInt
"simple trace"
[__i|
Expand Down

0 comments on commit 3bec4b2

Please sign in to comment.