objectionary / objectionary/eo
Three `@ms` assertions in `EoSyntaxTest` cannot fail since `Millis` rounds up
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 251
- Avg merge
- 21h 30m
- Merged PRs (30d)
- 726
Description
Millis.asString() at eo-parser/src/main/java/org/eolang/parser/Millis.java:33 computes (this.nanos + 999_999L) / 1_000_000L, so any span of one nanosecond or more prints as at least 1. The span that EoSyntax.parsed() measures runs from eo-parser/src/main/java/org/eolang/parser/EoSyntax.java:117 to :128 and covers a full input read, a Manifests lookup and the entire source walk, so it is never zero nanoseconds.
That makes Matchers.greaterThan(0L) at eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java:103, :114 and :140 a condition the arithmetic guarantees. measuresRealParsingTime claims "ms attribute is not a measured elapsed time" and would pass against a hard-coded 1, which is exactly the regression #7111 was filed for. measuresParsingTimeOnEveryCall claims the second parsed() call measures its own elapsed time and would pass just as well if the value were cached from the first. measuresSubMillisecondParsingTime names rounding in its failure message while asserting nothing but > 0, and MillisTest.roundsSubMillisecondSpanUpToOne at eo-parser/src/test/java/org/eolang/parser/MillisTest.java:19 already pins that rounding down as a unit test.
All that the three still prove is that @ms is present and parses as a number, and parsesSimpleCode asserts that already at EoSyntaxTest.java:86. The fixture lost its reason to exist in the same change: b060ac6ad1 deleted "long enough for its parsing to last more than a single millisecond" from the LargeProgram docblock at eo-parser/src/test/java/fixtures/LargeProgram.java:15, yet both tests still parse its 61 lines to assert something that no longer depends on them.
Each of the three should assert a relation the rounding cannot satisfy on its own, the way reportsMsWithinSaneBound at EoSyntaxTest.java:119 still does — a unit error there blows the bound. The ones that cannot be given such a relation add nothing over parsesSimpleCode and can go.
@yegor256
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the three assertions in eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java at lines 103, 114, and 140, then read Millis.java:33 and MillisTest.java:19 to understand the rounding guarantee. Compare them with reportsMsWithinSaneBound at line 119 and parsesSimpleCode at line 86. Done means the remaining tests verify behavior not guaranteed by rounding, with redundant assertions or fixture dependence removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100