1.0.0 release

This commit is contained in:
2026-06-01 18:27:40 -07:00
parent b1ab0f102c
commit 1f20fcab20
1151 changed files with 230703 additions and 14 deletions
@@ -0,0 +1,46 @@
// SnippetHarnessTests.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Testing
import Foundation
@testable import LyrebirdLiveCompile
#if os(macOS)
@Suite("SnippetHarness")
struct SnippetHarnessTests {
@Test
func wrappedSourceContainsPreambleAndUserBody() {
let wrapped: WrappedSnippet = SnippetHarness.wrap(userBody: "context.reportMessage(\"hello\")")
#expect(wrapped.source.contains("import LyrebirdSynth"))
#expect(wrapped.source.contains("import LyrebirdLiveCompile"))
#expect(wrapped.source.contains("@_cdecl(\"lyrebird_snippet_entry\")"))
#expect(wrapped.source.contains("Unmanaged<SnippetContext>"))
#expect(wrapped.source.contains("context.reportMessage(\"hello\")"))
}
@Test
func userBodyLineOffsetMatchesActualSourceLayout() {
let body: String = "let x = 1"
let wrapped: WrappedSnippet = SnippetHarness.wrap(userBody: body)
let lines: [String.SubSequence] = wrapped.source.split(separator: "\n", omittingEmptySubsequences: false)
// Line at index `offset - 1` (0-indexed) should be the first line of the body.
let bodyLineIndex: Int = wrapped.userBodyLineOffset - 1
#expect(bodyLineIndex >= 0)
#expect(bodyLineIndex < lines.count)
#expect(String(lines[bodyLineIndex]) == body)
}
@Test
func multilineUserBodyIsPreservedVerbatim() {
let body: String = "let a = 1\nlet b = 2\ncontext.reportMessage(\"\\(a + b)\")"
let wrapped: WrappedSnippet = SnippetHarness.wrap(userBody: body)
#expect(wrapped.source.contains(body))
}
}
#endif