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:
os:
- ubuntu-latest
- windows-latest
- macos-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# lix
- uses: lix-pm/setup-lix@master
- uses: https://k7izh9.gitea.cloud/kiss-lang/setup-lix@1.0.2
with:
lix-version: 15.12.0

View File

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

View File

@@ -47,16 +47,16 @@
// Test block insertion
(project.insertBlock 0 "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
(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"))
// Test block editing
(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
(assert !(project.deleteBlock 2))
@@ -64,22 +64,22 @@
(assert !(project.editBlock 2 "edit" "locked block"))
(project.toggleLock 2)
(assert (project.deleteBlock 2))
(assertExportContents project "here\n\nnot " "!\n")
(assertExportContents project "here\n\nnot \n\n" "!\n")
// Test undo/redo delete
(project.undoChange)
(assertExportContents project "here\n\nnot here" "!\n!!!\n")
(assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n")
(project.redoChange)
(assertExportContents project "here\n\nnot " "!\n")
(assertExportContents project "here\n\nnot \n\n" "!\n")
(project.undoChange)
(project.undoChange)
// Test undo/redo edit:
(assert (project.undoChange))
(assertExportContents project "here\n\nnot there" "!\n")
(assertExportContents project "here\n\nnot \n\nthere" "!\n")
(project.redoChange)
(assertExportContents project "here\n\nnot here" "!\n!!!\n")
(assertExportContents project "here\n\nnot \n\nhere" "!\n!!!\n")
)
(rmrf "test.tct")