Skip to content

Commit ce6e86e

Browse files
committed
fix(measurements): keep relative and governed claims silent
1 parent 3172b12 commit ce6e86e

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

‎internal/measurements/measurements.go‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,12 @@ func governingClauseStart(line string, nameAt int) int {
820820
start := 0
821821
for index := 0; index < nameAt; index++ {
822822
switch line[index] {
823-
case ';', ':', '.', '!', '?':
823+
case ';', ':':
824824
start = index + 1
825+
default:
826+
if sentenceTerminatorAt(line, index) {
827+
start = index + 1
828+
}
825829
}
826830
}
827831
return start
@@ -969,8 +973,7 @@ func durationHasElapsedRole(text string, begin, end int) bool {
969973

970974
func comparativeDurationSuffix(text string) bool {
971975
words := asciiWords(strings.TrimSpace(text))
972-
return len(words) >= 2 && words[1] == "than" &&
973-
(words[0] == "less" || words[0] == "more" || words[0] == "faster" || words[0] == "slower")
976+
return len(words) >= 2 && words[1] == "than"
974977
}
975978

976979
// affirmativeCueLead binds the result verb to the measured name. These are the
@@ -1217,22 +1220,29 @@ var clauseSeparators = []string{
12171220
// sits between two digits.
12181221
func sentenceEnd(line string, from int) int {
12191222
for index := from; index < len(line); index++ {
1220-
switch line[index] {
1221-
case '.', '!', '?':
1222-
default:
1223-
continue
1224-
}
1225-
if line[index] == '.' && index > 0 && index+1 < len(line) &&
1226-
isDigitByte(line[index-1]) && isDigitByte(line[index+1]) {
1227-
continue
1228-
}
1229-
if index+1 >= len(line) || line[index+1] == ' ' || line[index+1] == '\t' {
1223+
if sentenceTerminatorAt(line, index) {
12301224
return index
12311225
}
12321226
}
12331227
return -1
12341228
}
12351229

1230+
func sentenceTerminatorAt(line string, index int) bool {
1231+
if index < 0 || index >= len(line) {
1232+
return false
1233+
}
1234+
switch line[index] {
1235+
case '.', '!', '?':
1236+
default:
1237+
return false
1238+
}
1239+
if line[index] == '.' && index > 0 && index+1 < len(line) &&
1240+
isDigitByte(line[index-1]) && isDigitByte(line[index+1]) {
1241+
return false
1242+
}
1243+
return index+1 >= len(line) || line[index+1] == ' ' || line[index+1] == '\t'
1244+
}
1245+
12361246
func isDigitByte(b byte) bool { return b >= '0' && b <= '9' }
12371247

12381248
// nextNameShaped returns the offset of the next token that looks like a name

‎internal/measurements/measurements_test.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,8 @@ func TestRangesAndComparisonsAreNotElapsedTimeEvidence(t *testing.T) {
15481548
"TestX took 1s–10s.",
15491549
"TestX took 9s less than the suite.",
15501550
"TestX took 9s more than the baseline.",
1551+
"TestX took 9s longer than TestY.",
1552+
"TestX took 9s shorter than the suite.",
15511553
} {
15521554
for _, entry := range []struct {
15531555
name string
@@ -1728,6 +1730,8 @@ func TestGoverningDenialAndHypothesisRemainAttachedToName(t *testing.T) {
17281730
"It is not true that TestX took 9s.",
17291731
"It isn't true that TestX took 9s.",
17301732
"It isn’t true that TestX took 9s.",
1733+
"It is not true that after 0.5s TestX took 9s.",
1734+
"It is not true that in v1.2 TestX took 9s.",
17311735
"If TestX took 9s, it would exceed the budget.",
17321736
"Unless TestX took 9s, the premise does not apply.",
17331737
} {

0 commit comments

Comments
 (0)