-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I have a relatively complex generator (which is not even complete by now).
@cron_expression_value list(of:
choose(from: [
value(:*),
int(),
tuple(like: {value(:L), int()})
]
), min: 1, max: 3)
test "parse & compose gets the same struct" do
ptest [cron_expression: Pollution.VG.struct(%Crontab.CronExpression{
extended: value(false),
reboot: value(false),
second: value([:*]),
minute: @cron_expression_value,
hour: @cron_expression_value,
day: @cron_expression_value,
month: @cron_expression_value,
weekday: @cron_expression_value,
year: @cron_expression_value
})] do
IO.inspect cron_expression
cron_string = Crontab.CronExpression.Composer.compose(cron_expression)
assert Crontab.CronExpression.Parser.parse!(cron_string, false) == cron_expression
end
endI expect this code to always generate the cron_expression property as a struct of Crontab.CronExpression.
$ mix test
.............................................................................................~e[* 0L,0 0L,-1L 0L 0,*,0L *]
~e[* 0L,0 0L,-1L 0L 0,*,0L *]
%{day: [L: 0, L: -1], extended: false, hour: [{:L, 0}, 0], minute: [:*],
month: [L: 0], reboot: false, second: [:*], weekday: [0, :*, {:L, 0}],
year: [:*]}
1) test parse & compose gets the same struct (Crontab.FunctionalTest)
test/crontab/functional_test.exs:140
** (FunctionClauseError) no function clause matching in Crontab.CronExpression.Composer.compose/1
stacktrace:
(crontab) lib/crontab/cron_expression/composer.ex:26: Crontab.CronExpression.Composer.compose(%{day: [L: 0, L: -1], extended: false, hour: [{:L, 0}, 0], minute: [:*], month: [L: 0], reboot: false, second: [:*], weekday: [0, :*, {:L, 0}], year: [:*]})
test/crontab/functional_test.exs:153: anonymous fn/1 in Crontab.FunctionalTest.test parse & compose gets the same struct/1
lib/pollution/shrinker.ex:41: Pollution.Shrinker.shrink/3
lib/quixir/shrinker.ex:48: Quixir.Shrinker.try_to_shrink/2
lib/quixir/shrinker.ex:31: Quixir.Shrinker.start_shrink/1
test/crontab/functional_test.exs:141: anonymous fn/2 in Crontab.FunctionalTest.test parse & compose gets the same struct/1
(elixir) lib/enum.ex:1785: Enum.reduce_range_inc/4
test/crontab/functional_test.exs:141: (test)
....................................
Finished in 0.4 seconds
130 tests, 1 failure
Randomized with seed 522066The output shows, that in some cases the cron_expression is just a map and not of type struct Crontab.CronExpression.
I'm not certain, that I did everything correct, but it seems like an error to me.
Metadata
Metadata
Assignees
Labels
No labels