← every case · 2000 · string forms

2190-triple_quote_read_as_three_short_ones

Groovy opens a string that runs over several lines with three apostrophes. A counter that reads the first apostrophe as the start of an ordinary one line string ends that string where the line ends, and is then outside a string when it meets the two comment openers below, so it reads them as comments instead of as the text they are. The second one opens a block that nothing closes, which takes the rest of the file with it. A counter that does not treat the apostrophe as a string symbol of Groovy at all ends up in the same place, outside a string when the openers arrive. Case 2090 holds the same three character delimiter in Python

read ascloc.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.groovy
1codedef a = '''
2code// this is text inside the string
3code/* and so is this
4code'''
5codedef b = 1

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

a // at the head of a line opens a comment inside a triple apostrophe string too, so that line counts as one, while the /* under it opens nothing and takes no line with it

the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 4 code · 1 comments

cloc --json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy

mezura.content ✓ agrees
the rules ask5 lines · 5 code · 0 comments · 0 extra
it answers5 lines · 5 code · 0 comments · 0 extra

mezura cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy --output json --hide timing --counting content

mezura.region ✓ agrees
the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 5 code · 0 comments

mezura cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy --output json --hide timing --counting region

scc.default ✗ fails

an apostrophe does not open a string in Groovy, so the three apostrophes are code, the // below counts as a comment and the /* under it opens a block that nothing closes

the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 1 code · 4 comments

scc --format json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy

tokei.default ✗ fails

an apostrophe does not open a string in Groovy, so the three apostrophes are code, the // below counts as a comment and the /* under it opens a block that nothing closes

the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 1 code · 4 comments

tokei --output json cases/2000-string_forms/2190-triple_quote_read_as_three_short_ones/input.groovy