Blame tests/syntax-highlighting/file.groovy

Packit a7d494
#!/usr/bin/env groovy
Packit a7d494
Packit a7d494
// Single-line comment. TODO markers work.
Packit a7d494
/* Multi-line comment.
Packit a7d494
   TODO markers work. */
Packit a7d494
Packit a7d494
'line' \
Packit a7d494
    + 'continuation'
Packit a7d494
Packit a7d494
def tsq = '''Triple single-quoted string.
Packit a7d494
Packit a7d494
    Escapes work: \' \n \123 \u12ab \
Packit a7d494
    Interpolation doesn't work: $x ${x}
Packit a7d494
'''
Packit a7d494
Packit a7d494
def sq = 'Single-quoted string. Escapes work: \' \r \45 \u45CD \
Packit a7d494
    Interpolation does not: $x ${x}'
Packit a7d494
Packit a7d494
def tdq = """Triple double-quoted string.
Packit a7d494
Packit a7d494
    Escapes work: \" \f \6 \uABCD \
Packit a7d494
    Interpolation works: $x._y.z0 ${x + 5}
Packit a7d494
"""
Packit a7d494
Packit a7d494
def dq = "Double-quoted string. Escapes work: \" \b \7 \u5678 \
Packit a7d494
    So does interpolation: $_abc1 ${x + "abc"}"
Packit a7d494
Packit a7d494
def slashy = /Slashy string.
Packit a7d494
Packit a7d494
    There are only two escape sequences: \/ \
Packit a7d494
    Interpolation works: $X ${-> X}
Packit a7d494
    Dollars $ and backslashes \ on their own are interpreted literally./
Packit a7d494
Packit a7d494
def notSlashy = 1 /2/ 3 // not a slashy string; just two division operators
Packit a7d494
Packit a7d494
def dollarSlashy = $/Dollar slashy string.
Packit a7d494
Packit a7d494
    There are three escape sequences: $$ $/ \
Packit a7d494
    Interpolation works: $_ ${true}
Packit a7d494
    Dollars $ and backslashes \ on their own are interpreted literally./$
Packit a7d494
Packit a7d494
0b10i + 0b0110_1011 // binary numbers
Packit a7d494
0 + 123L + 456_789 // decimal numbers
Packit a7d494
0xab + 0xcd_efG // hexadecimal numbers
Packit a7d494
Packit a7d494
01_23.45_67g + 1e-23f + 2d + 08.80 // floating-point numbers
Packit a7d494
Packit a7d494
trait Test {
Packit a7d494
    void foo(List list) {
Packit a7d494
        def sum = 0
Packit a7d494
        for (n in list) sum += n as int
Packit a7d494
        println sum
Packit a7d494
    }
Packit a7d494
}
Packit a7d494