Whole file

cuu508/cronsim

The author described this change as Fix more weekday handling bugs. It counts as a record because the check below fails on the code as it stood at 9325f729b and passes on 03fc8bd91, with nothing else changed between the two runs.

Fix saved2021-04-28
Sharing licenceBSD-3-Clause · LICENSE
Change size+10 7

What the code was meant to do, written into the code itself as a save note

Fix more weekday handling bugs

The change

1919 list(range(0, 7)),
2020 ]
2121
22-SYMBOLIC_DAYS = "MON TUE WED THU FRI SAT SUN".split()
22+SYMBOLIC_DAYS = "SUN MON TUE WED THU FRI SAT".split()
2323 SYMBOLIC_MONTHS = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC".split()
2424
2525
3030
3131 if field == Field.DOW:
3232 if value.upper() in SYMBOLIC_DAYS:
33- value = SYMBOLIC_DAYS.index(value.upper()) + 1
33+ value = SYMBOLIC_DAYS.index(value.upper())
3434
3535 return int(value)
3636
5454 items = _parse(field, term)
5555 if len(items) == 1:
5656 start = items[0]
57- items = [v for v in RANGES[field] if v >= start]
57+ end = max(RANGES[field])
58+ items = list(range(start, end + 1))
5859
5960 return items[::int(step)]
6061
6465 end = _int(field, end)
6566 return list(range(start, end + 1))
6667
67- if value == "L" and field == Field.DAY:
68+ if field == Field.DAY and value in ("L", "l"):
6869 return [CronSim.LAST]
6970
7071 return [_int(field, value)]
206207
207208
208209 if __name__ == '__main__':
209- a = CronSim("0 1 * * */2", datetime.now())
210- for i in range(0, 10):
211- print("Here's what we got: ", next(a))
210+ # a = CronSim("0 1 * * */2", datetime.now())
211+ # for i in range(0, 10):
212+ # print("Here's what we got: ", next(a))
213+
214+ print(_parse(Field.DAY, "0/10"))
212215

The check that tells the two apart

failpass·test_cronsim.py::TestParse::test_it_parses_day_lowercase_l

Check file test_cronsim.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it9325f729b98d47fe2891969b167dee77712e5d5b
Broken version dated2021-04-28
Modulecronsim
Units changed_int, _parse
Fingerprint3ea150d2f7e5b8de
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in cuu508/cronsim