Skip to content

Commit 57c17a9

Browse files
committed
Fix tests
1 parent 086538c commit 57c17a9

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

Sources/ZolangCore/Frontend/Models/Nodes/DescriptionList.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ public struct DescriptionList: Node {
1515
public init(tokens: [Token], context: inout ParserContext) throws {
1616
var tokens = tokens
1717
context.line += tokens.trimLeadingNewlines()
18-
19-
guard tokens.first?.type == .identifier else {
20-
throw ZolangError(type: .missingIdentifier,
21-
file: context.file,
22-
line: context.line)
23-
}
24-
18+
2519
var properties: [(Bool, String, String?, Type)] = []
2620
var functions: [(Bool, String, String?, Function)] = []
2721

@@ -35,7 +29,7 @@ public struct DescriptionList: Node {
3529
skipping: [ .newline ],
3630
startingAt: i) {
3731
isStatic = true
38-
tokens.removeFirst()
32+
i = tokens.index(of: [ .static ], startingAt: i)! + 1
3933
}
4034

4135
context.line += tokens.trimLeadingNewlines()

Sources/ZolangCore/Frontend/TokenExtensions/Token+Convenience.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ extension Token {
3232
return Token(type: .return)
3333
case Token.make.type.rawValue:
3434
return Token(type: .make)
35+
case Token.static.type.rawValue:
36+
return Token(type: .static)
3537
default:
3638
return nil
3739
}
@@ -133,6 +135,10 @@ extension Token {
133135
return Token(type: .make)
134136
}
135137

138+
public static var `static`: Token {
139+
return Token(type: .`static`)
140+
}
141+
136142
public static var from: Token {
137143
return Token(type: .from)
138144
}

Tests/ZolangTests/DescriptionListTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class DescriptionListTests: XCTestCase {
3939
name as text
4040
friends as list of Person
4141
street as text
42-
house_number as number
42+
static house_number privately as number
4343
44-
address return text from () {
44+
address privately return text from () {
4545
return "${street} ${house_number}"
4646
}
4747

Tests/ZolangTests/StringLexerTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class StringLexerTests: XCTestCase {
178178
"be",
179179
"of",
180180
"if",
181-
"else"
181+
"else",
182+
"static"
182183
]
183184

184185
XCTAssert(validStrings.joined(separator: "|").sorted() == regex.sorted())

0 commit comments

Comments
 (0)