Files
xtool/Tests/XToolTests/CommandInvocationParsingTests.swift
Kabir Oberai 3bebb76013 wip: hot reloading
Discriminate with module name

Fully working

Changes

Fix linux

changes

allow customizing xload path

Lint
2026-05-30 03:10:17 -04:00

26 lines
977 B
Swift

import Testing
@testable import XToolSupport
@Test func commandParser() throws {
func sut(_ string: some StringProtocol) throws -> [String] {
try CommandParser.parse(string)
}
#expect(try sut(#""#).isEmpty)
#expect(try sut(#"foo"#) == ["foo"])
#expect(try sut(#"foo "#) == ["foo"])
#expect(try sut(#"foo one two"#) == ["foo", "one", "two"])
#expect(try sut(#"foo 'one two' three"#) == ["foo", "one two", "three"])
#expect(try sut(#"foo 'one!two' three"#) == ["foo", "one!two", "three"])
#expect(try sut(#"foo one\!two three"#) == ["foo", "one!two", "three"])
#expect(try sut(#"foo one\'two three"#) == ["foo", "one'two", "three"])
#expect(try sut(#"foo one'two three'four five"#) == ["foo", "onetwo threefour", "five"])
#expect(throws: CommandParser.Errors.unclosedQuote) {
try sut(#"foo one two' three"#)
}
#expect(throws: CommandParser.Errors.unpairedEscape) {
try sut(#"foo a b \"#)
}
}