@testable import PureYAML import Testing @Suite("A dash before a flow indicator") struct FlowDashScalarTests { @Test("A `-` immediately before a flow indicator is not a valid scalar", arguments: [ "[-]\n", // a lone dash before `]` "---\n- [-, -]\n", // dashes before `,` and `]` "{a: -}\n", // a lone dash before `}` ]) func test_dashBeforeFlowIndicatorRejected(_ yaml: String) throws { #expect(throws: PureYAML.Parsing.ParseError.self) { try PureYAML.parse(yaml) } } @Test("A dash followed by a non-indicator character stays a valid scalar", arguments: [ "[-1, -2]\n", // negative numbers "[a-b, c-d]\n", // a dash inside a scalar "[-x, -y]\n", // a dash starting a word "[\"-\", '-']\n", // a quoted dash ]) func test_validDashScalars(_ yaml: String) throws { _ = try PureYAML.parse(yaml) } }