fix #55 newlines in function declarations and constructors
This commit is contained in:
parent
0526cdfb38
commit
8d1cafae80
@ -622,6 +622,8 @@ class Compiler(
|
|||||||
var endTokenType: Token.Type? = null
|
var endTokenType: Token.Type? = null
|
||||||
val startPos = cc.savePos()
|
val startPos = cc.savePos()
|
||||||
|
|
||||||
|
cc.skipWsTokens()
|
||||||
|
|
||||||
while (endTokenType == null) {
|
while (endTokenType == null) {
|
||||||
var t = cc.next()
|
var t = cc.next()
|
||||||
when (t.type) {
|
when (t.type) {
|
||||||
@ -679,7 +681,7 @@ class Compiler(
|
|||||||
|
|
||||||
// important: valid argument list continues with ',' and ends with '->' or ')'
|
// important: valid argument list continues with ',' and ends with '->' or ')'
|
||||||
// otherwise it is not an argument list:
|
// otherwise it is not an argument list:
|
||||||
when (val tt = cc.next().type) {
|
when (val tt = cc.nextNonWhitespace().type) {
|
||||||
Token.Type.RPAREN -> {
|
Token.Type.RPAREN -> {
|
||||||
// end of arguments
|
// end of arguments
|
||||||
endTokenType = tt
|
endTokenType = tt
|
||||||
|
@ -106,4 +106,15 @@ class OOTest {
|
|||||||
}
|
}
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testMultilineConstructor() = runTest {
|
||||||
|
eval("""
|
||||||
|
class Point(
|
||||||
|
x,
|
||||||
|
y
|
||||||
|
)
|
||||||
|
assertEquals(Point(1,2), Point(1,2) )
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
}
|
}
|
@ -3049,5 +3049,22 @@ class ScriptTest {
|
|||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testMultilineFnDeclaration() = runTest {
|
||||||
|
eval("""
|
||||||
|
fun test(
|
||||||
|
x = 1,
|
||||||
|
y = 2
|
||||||
|
) {
|
||||||
|
x * y
|
||||||
|
}
|
||||||
|
assertEquals( 10, test(5) )
|
||||||
|
assertEquals( 42, test(
|
||||||
|
6,
|
||||||
|
7
|
||||||
|
) )
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user