v1.4.0 release: live-coding scratch editor, interpreted Graph DSL, ClosureSynthesizer + SampleLoop
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// GraphDSLDiagnosticMapperTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if os(macOS)
|
||||
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
|
||||
Reference in New Issue
Block a user