Commit eb5181c6 authored by Johannes Schriewer's avatar Johannes Schriewer

Bugfix: Fix the failing tests (API change in Path())

parent fc674c31
Pipeline #1684 failed with stage
Subproject commit e006740b3a65a4c99b06ca99ed986230d1268495
Subproject commit 39850a7d598ace35adca4dafe4c2c64e829f678f
......@@ -19,7 +19,7 @@ public struct ScannerInfo {
}
final public class Scanner {
var content: String
var index: String.Index
var current: ScannerInfo? = nil
......@@ -27,7 +27,7 @@ final public class Scanner {
private var shouldStall = false
var line: Int = 1
var column: Int = 1
var column: Int = 1
public init(content: String) {
self.content = content
......@@ -52,9 +52,9 @@ final public class Scanner {
shouldStall = false
return current
}
if index == content.endIndex {
current = nil
current = nil
}
else {
current = ScannerInfo(character: content[index], line: line, column: column)
......@@ -62,14 +62,14 @@ final public class Scanner {
if current?.character == "\n" {
line += 1
column = 1
column = 1
}
else {
column += 1
}
}
return current
return current
}
public func peek() -> ScannerInfo? {
......
......@@ -34,14 +34,14 @@ class PackageTests: Test {
let filename = #file
static func testBasic() throws {
let filepath = Path(string: "tests/collateral/basic.atpkg")
let filepath = Path("tests/collateral/basic.atpkg")
guard let parser = try Parser(filepath: filepath) else {
try test.assert(false); return
}
let result = try parser.parse()
let package = try Package(type: result, overlay: [], pathOnDisk: Path(string: "tests/collateral"), focusOnTask: nil)
let package = try Package(type: result, overlay: [], pathOnDisk: Path("tests/collateral"), focusOnTask: nil)
try test.assert(package.name == "basic")
try test.assert(package.version == "0.1.0-dev")
......@@ -58,7 +58,7 @@ class PackageTests: Test {
}
static func testImport() throws {
let filepath = Path(string: "tests/collateral/import_src.atpkg")
let filepath = Path("tests/collateral/import_src.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
try test.assert(package.tasks["import_dst.build"] != nil)
......@@ -66,7 +66,7 @@ class PackageTests: Test {
}
static func testOverlays() throws {
let filepath = Path(string: "tests/collateral/overlays.atpkg")
let filepath = Path("tests/collateral/overlays.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
guard let compileOptions = package.tasks["build"]?["compile-options"]?.vector else {
fatalError("No compile options?")
......@@ -127,7 +127,7 @@ class PackageTests: Test {
}
static func testExportedOverlays() throws {
let filepath = Path(string: "tests/collateral/overlays_src.atpkg")
let filepath = Path("tests/collateral/overlays_src.atpkg")
let package2 = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
guard let compileOptions2 = package2.tasks["build"]?["compile-options"]?.vector else {
......@@ -144,7 +144,7 @@ class PackageTests: Test {
}
static func testChainedImports () throws {
let filepath = Path(string: "tests/collateral/chained_imports/a.atpkg")
let filepath = Path("tests/collateral/chained_imports/a.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
guard let a_default_unqualified = package.tasks["default"] else {
fatalError("No default task")
......@@ -172,7 +172,7 @@ class PackageTests: Test {
}
static func testImportPaths () throws {
let filepath = Path(string: "tests/collateral/import_paths/a.atpkg")
let filepath = Path("tests/collateral/import_paths/a.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
guard let a_default_unqualified = package.tasks["default"] else {
fatalError("No default task")
......@@ -205,7 +205,7 @@ class PackageTests: Test {
}
static func testChainedImportOverlays() throws {
let filepath = Path(string: "tests/collateral/chained_import_overlays/a.atpkg")
let filepath = Path("tests/collateral/chained_import_overlays/a.atpkg")
let package = try Package(filepath: filepath, overlay: ["b.foo"], focusOnTask: nil)
guard let a_qualified = package.tasks["a.default"] else { print("error"); try test.assert(false); return }
guard let options = a_qualified["compile-options"]?.vector else {
......@@ -219,7 +219,7 @@ class PackageTests: Test {
}
static func testRequireOverlays() throws {
let filepath = Path(string: "tests/collateral/require_overlays.atpkg")
let filepath = Path("tests/collateral/require_overlays.atpkg")
do {
let p = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
try p.tasks["build"]?.checkRequiredOverlays()
......@@ -239,7 +239,7 @@ class PackageTests: Test {
}
static func nonVectorImport() throws {
let filepath = Path(string: "tests/collateral/non_vector_import.atpkg")
let filepath = Path("tests/collateral/non_vector_import.atpkg")
if let _ = try? Package(filepath: filepath, overlay: [], focusOnTask: nil) {
try test.assert(false) //no diagnostic
}
......
......@@ -19,20 +19,20 @@ import atpkg
func outputBaseline(lexer: Lexer) {
print("--- baseline ---")
while let token = lexer.next() {
let type = String(reflecting: token.type).replacingOccurrences(of: "atpkgparser.", with: "")
let type = String(reflecting: token.type).replacing(searchTerm: "atpkgparser.", replacement: "")
var value = ""
switch token.type {
case .Terminal: value = "\\n"
default: value = token.value
}
let output = "try test.assert(lexer.next() == Token(type: \(type), value: \"\(value)\", line: \(token.line), column: \(token.column)))"
print(output)
}
print("--- end baseline ---")
}
class LexerTests: Test {
required init() {}
let tests = [
......@@ -40,14 +40,14 @@ class LexerTests: Test {
]
let filename = #file
static func testBasic() throws {
let filepath = "./tests/collateral/basic.atpkg"
let filepath = Path("tests/collateral/basic.atpkg")
let content: String = try NSString(contentsOfFile: filepath, encoding: NSUTF8StringEncoding).toString
let content: String = try String(loadFromFile: filepath)!
let scanner = Scanner(content: content)
let lexer = Lexer(scanner: scanner)
try test.assert(lexer.next() == Token(type: atpkg.TokenType.Comment, value: " This is the most basic of sample files.", line: 1, column: 1))
try test.assert(lexer.next() == Token(type: atpkg.TokenType.Terminal, value: "\n", line: 2, column: 1))
try test.assert(lexer.next() == Token(type: atpkg.TokenType.OpenParen, value: "(", line: 3, column: 1))
......
......@@ -25,7 +25,7 @@ class ParserTests: Test {
let filename = #file
static func testBasic() throws {
let filepath = Path(string: "tests/collateral/basic.atpkg")
let filepath = Path("tests/collateral/basic.atpkg")
guard let parser = try Parser(filepath: filepath) else {
try test.assert(false); return
}
......
......@@ -29,7 +29,7 @@ func outputBaseline(scanner: Scanner) {
case "\"": str = "\\\""
default: break
}
print("try test.assert(scanner.next()?.character == \"\(str)\")")
}
print("--- end baseline ---")
......@@ -44,11 +44,11 @@ class ScannerTests: Test {
let filename = #file
static func testBasicClj() throws {
let filepath = "./tests/collateral/basic.atpkg"
let content: String = try NSString(contentsOfFile: filepath, encoding: NSUTF8StringEncoding).toString
let filepath = Path("tests/collateral/basic.atpkg")
let content: String = try String(loadFromFile: filepath)!
let scanner = Scanner(content: content)
try test.assert(scanner.next()?.character == ";")
try test.assert(scanner.next()?.character == ";")
try test.assert(scanner.next()?.character == " ")
......
......@@ -25,7 +25,7 @@ class SubstitutionTests: Test {
let filename = #file
static func testBasic() throws {
let filepath = Path(string: "tests/collateral/basic.atpkg")
let filepath = Path("tests/collateral/basic.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
try test.assert(evaluateSubstitutions(input: "${test_substitution}", package: package) == "test_substitution")
try test.assert(evaluateSubstitutions(input: "foobly-doobly-doo ${test_substitution} doobly-doo", package: package) == "foobly-doobly-doo test_substitution doobly-doo")
......@@ -33,7 +33,7 @@ class SubstitutionTests: Test {
}
static func testCollectSources() throws {
let filepath = Path(string: "tests/collateral/collect_sources/build.atpkg")
let filepath = Path("tests/collateral/collect_sources/build.atpkg")
let package = try Package(filepath: filepath, overlay: [], focusOnTask: nil)
try test.assert(evaluateSubstitutions(input: "${collect_sources:default}", package: package) == "tests/collateral/collect_sources/src/a.swift tests/collateral/collect_sources/src/b.swift")
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment