fix unit tests
All checks were successful
CI / test (ubuntu-latest) (push) Successful in 58s

This commit is contained in:
2025-09-14 19:22:54 -05:00
parent 6e2bd71c1a
commit 5c5ef7b4de
3 changed files with 21 additions and 20 deletions

View File

@@ -8,14 +8,12 @@ jobs:
matrix: matrix:
os: os:
- ubuntu-latest - ubuntu-latest
- windows-latest
- macos-latest
fail-fast: false fail-fast: false
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
# lix # lix
- uses: lix-pm/setup-lix@master - uses: https://k7izh9.gitea.cloud/kiss-lang/setup-lix@1.0.2
with: with:
lix-version: 15.12.0 lix-version: 15.12.0

View File

@@ -62,9 +62,9 @@
(+= tctContent "${block.id} ${block.locked}\n") (+= tctContent "${block.id} ${block.locked}\n")
(File.saveContent tctFile tctContent)))) (File.saveContent tctFile tctContent))))
(method :Void _saveBlock [:Block block] (method :Void _saveBlock [:Block block &opt :Bool lastBlock]
(when block.inText (when block.inText
(unless (block.inText.endsWith inBlockTerminator) (unless (or lastBlock (block.inText.endsWith inBlockTerminator))
(+= block.inText inBlockTerminator))) (+= block.inText inBlockTerminator)))
(File.saveContent "${blockDir}/${block.id}.${inExtension}" block.inText) (File.saveContent "${blockDir}/${block.id}.${inExtension}" block.inText)
(when block.outText (when block.outText
@@ -92,8 +92,11 @@
(_saveTctFile) (_saveTctFile)
(doFor block blocks (let [lastBlock (blocks.pop)]
(_saveBlock block)) (doFor block blocks
(_saveBlock block))
(_saveBlock lastBlock true)
(blocks.push lastBlock))
(_saveOutputFiles) (_saveOutputFiles)
@@ -123,7 +126,7 @@
((objectWith [type Insert] blockIndex newBlock) ((objectWith [type Insert] blockIndex newBlock)
(blocks.insert blockIndex newBlock) (blocks.insert blockIndex newBlock)
(_saveTctFile) (_saveTctFile)
(_saveBlock newBlock)) (_saveBlock newBlock (= blockIndex (- blocks.length 1))))
((objectWith [type Delete] blockIndex oldBlock) ((objectWith [type Delete] blockIndex oldBlock)
(when .locked (nth blocks blockIndex) (return false)) (when .locked (nth blocks blockIndex) (return false))
(blocks.splice blockIndex 1) (blocks.splice blockIndex 1)
@@ -134,7 +137,7 @@
(return false)) (return false))
(setNth blocks blockIndex newBlock) (setNth blocks blockIndex newBlock)
(_saveTctFile) (_saveTctFile)
(_saveBlock newBlock)) (_saveBlock newBlock (= blockIndex (- blocks.length 1))))
((objectWith [type JoinDown] blockIndex oldBlock newBlock) ((objectWith [type JoinDown] blockIndex oldBlock newBlock)
(when (or (isNull newBlock) oldBlock.locked newBlock.locked) (when (or (isNull newBlock) oldBlock.locked newBlock.locked)
(return false)) (return false))
@@ -142,9 +145,9 @@
// allow subcommands to record their simple step-by-step history, // allow subcommands to record their simple step-by-step history,
// then return early // then return early
(return (and (return (and
(insertBlock blockIndex "${oldBlock.inText}${newBlock.inText}" "${oldBlock.outText}${newBlock.outText}" false) (deleteBlock (+ blockIndex 1))
(deleteBlock (+ blockIndex 2)) (deleteBlock (+ blockIndex 0))
(deleteBlock (+ blockIndex 1))))) (insertBlock blockIndex "${oldBlock.inText}${newBlock.inText}" "${oldBlock.outText}${newBlock.outText}" false))))
(never otherwise)) (never otherwise))
(changeHistory.push change) (changeHistory.push change)
(_saveOutputFiles) (_saveOutputFiles)

View File

@@ -47,16 +47,16 @@
// Test block insertion // Test block insertion
(project.insertBlock 0 "not " "!") (project.insertBlock 0 "not " "!")
(project.insertBlock 2 "not " "!") (project.insertBlock 2 "not " "!")
(assertExportContents project "not here\n\nnot there" "!\n!\n") (assertExportContents project "not \n\nhere\n\nnot \n\nthere" "!\n!\n")
// Test block deletion // Test block deletion
(project.deleteBlock 0) (project.deleteBlock 0)
(assertExportContents project "here\n\nnot there" "!\n") (assertExportContents project "here\n\nnot \n\nthere" "!\n")
(assertEquals 6 .length (FileSystem.readDirectory "${project.directory}/blocks")) (assertEquals 6 .length (FileSystem.readDirectory "${project.directory}/blocks"))
// Test block editing // Test block editing
(project.editBlock 2 "here" "!!!" true) (project.editBlock 2 "here" "!!!" true)
(assertExportContents project "here\n\nnot here" "!\n!!!\n") (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n")
// Test trying to delete locked block // Test trying to delete locked block
(assert !(project.deleteBlock 2)) (assert !(project.deleteBlock 2))
@@ -64,22 +64,22 @@
(assert !(project.editBlock 2 "edit" "locked block")) (assert !(project.editBlock 2 "edit" "locked block"))
(project.toggleLock 2) (project.toggleLock 2)
(assert (project.deleteBlock 2)) (assert (project.deleteBlock 2))
(assertExportContents project "here\n\nnot " "!\n") (assertExportContents project "here\n\nnot \n\n" "!\n")
// Test undo/redo delete // Test undo/redo delete
(project.undoChange) (project.undoChange)
(assertExportContents project "here\n\nnot here" "!\n!!!\n") (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n")
(project.redoChange) (project.redoChange)
(assertExportContents project "here\n\nnot " "!\n") (assertExportContents project "here\n\nnot \n\n" "!\n")
(project.undoChange) (project.undoChange)
(project.undoChange) (project.undoChange)
// Test undo/redo edit: // Test undo/redo edit:
(assert (project.undoChange)) (assert (project.undoChange))
(assertExportContents project "here\n\nnot there" "!\n") (assertExportContents project "here\n\nnot \n\nthere" "!\n")
(project.redoChange) (project.redoChange)
(assertExportContents project "here\n\nnot here" "!\n!!!\n") (assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n")
) )
(rmrf "test.tct") (rmrf "test.tct")