b6fdee8bfc
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
2.0 KiB
Swift
56 lines
2.0 KiB
Swift
// GraphDSLDiagnosticMapperTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#if os(macOS) || os(Linux)
|
|
import Testing
|
|
import LyrebirdGraphDSLEmbedded
|
|
@testable import LyrebirdLiveCompile
|
|
|
|
@Suite("GraphDSLDiagnosticMapper")
|
|
struct GraphDSLDiagnosticMapperTests {
|
|
|
|
@Test
|
|
func parseErrorMapsSpanToLineAndColumn() {
|
|
// Offset 4 in "abc\nX" → line 2, column 1 (the char after the newline).
|
|
let span: DSLSpan = DSLSpan.point(4)
|
|
let error: DSLParseError = DSLParseError(kind: .unexpectedCharacter("%"), span: span)
|
|
let diags: [Diagnostic] = GraphDSLDiagnosticMapper.diagnostics(for: error, source: "abc\n%")
|
|
#expect(diags.count == 1)
|
|
#expect(diags[0].line == 2)
|
|
#expect(diags[0].column == 1)
|
|
#expect(diags[0].severity == .error)
|
|
#expect(diags[0].message.contains("unexpected"))
|
|
}
|
|
|
|
@Test
|
|
func firstColumnOfFirstLineIsOneOne() {
|
|
let error: DSLParseError = DSLParseError(kind: .unclosedParen, span: DSLSpan.point(0))
|
|
let diags: [Diagnostic] = GraphDSLDiagnosticMapper.diagnostics(for: error, source: "OscSin(")
|
|
#expect(diags[0].line == 1)
|
|
#expect(diags[0].column == 1)
|
|
}
|
|
|
|
@Test
|
|
func buildErrorHasNoLine() {
|
|
let error: DSLBuildError = DSLBuildError.unknownBuiltin("Nope")
|
|
let diags: [Diagnostic] = GraphDSLDiagnosticMapper.diagnostics(for: error, source: "Nope()")
|
|
#expect(diags.count == 1)
|
|
#expect(diags[0].line == nil)
|
|
#expect(diags[0].message.contains("Nope"))
|
|
}
|
|
|
|
@Test
|
|
func offsetPastEndClampsToFinalPosition() {
|
|
let error: DSLParseError = DSLParseError(kind: .unclosedParen, span: DSLSpan.point(1_000))
|
|
let diags: [Diagnostic] = GraphDSLDiagnosticMapper.diagnostics(for: error, source: "ab\ncd")
|
|
// Two lines, second is "cd": clamps to line 2, column 3 (past 'd').
|
|
#expect(diags[0].line == 2)
|
|
#expect(diags[0].column == 3)
|
|
}
|
|
}
|
|
|
|
#endif
|