Simplify tests for JS and python.
This commit is contained in:
parent
4156e3bf91
commit
c28fe448be
@ -3,10 +3,8 @@ import { createStdinReader } from '@terrace-lang/js/readers/node-readline'
|
|||||||
|
|
||||||
const testName = process.argv[2]
|
const testName = process.argv[2]
|
||||||
|
|
||||||
|
async function linedata_basic(indent) {
|
||||||
const tests = {
|
const lineData = createLineData('', indent)
|
||||||
'linedata:basic': async () => {
|
|
||||||
const lineData = createLineData('')
|
|
||||||
const next = createStdinReader()
|
const next = createStdinReader()
|
||||||
|
|
||||||
while ((lineData.line = await next()) != null) {
|
while ((lineData.line = await next()) != null) {
|
||||||
@ -14,18 +12,9 @@ const tests = {
|
|||||||
const { level, indent, offsetHead, offsetTail, line } = lineData
|
const { level, indent, offsetHead, offsetTail, line } = lineData
|
||||||
console.log(`| level ${level} | indent ${indent} | offsetHead ${offsetHead} | offsetTail ${offsetTail} | line ${line} |`)
|
console.log(`| level ${level} | indent ${indent} | offsetHead ${offsetHead} | offsetTail ${offsetTail} | line ${line} |`)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
'linedata:tabs': async () => {
|
|
||||||
const lineData = createLineData('', '\t')
|
|
||||||
const next = createStdinReader()
|
|
||||||
|
|
||||||
while ((lineData.line = await next()) != null) {
|
async function linedata_head_tail () {
|
||||||
parseLine(lineData)
|
|
||||||
const { level, indent, offsetHead, offsetTail, line } = lineData
|
|
||||||
console.log(`| level ${level} | indent ${indent} | offsetHead ${offsetHead} | offsetTail ${offsetTail} | line ${line} |`)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'linedata:head-tail': async () => {
|
|
||||||
const lineData = createLineData('')
|
const lineData = createLineData('')
|
||||||
const next = createStdinReader()
|
const next = createStdinReader()
|
||||||
|
|
||||||
@ -37,8 +26,8 @@ const tests = {
|
|||||||
|
|
||||||
console.log(`| head ${head} | tail ${tail} |`)
|
console.log(`| head ${head} | tail ${tail} |`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const test = tests[testName]
|
if (testName === 'linedata:basic') await linedata_basic()
|
||||||
await test()
|
if (testName === 'linedata:tabs') await linedata_basic('\t')
|
||||||
|
if (testName === 'linedata:head-tail') await linedata_head_tail()
|
||||||
|
@ -13,8 +13,8 @@ def next():
|
|||||||
# return None if there actually is no result.
|
# return None if there actually is no result.
|
||||||
return line.rstrip('\n') if len(line) > 0 else None
|
return line.rstrip('\n') if len(line) > 0 else None
|
||||||
|
|
||||||
def linedata_basic ():
|
def linedata_basic (indent):
|
||||||
lineData = createLineData('')
|
lineData = createLineData('', indent)
|
||||||
|
|
||||||
while (l := next()) != None:
|
while (l := next()) != None:
|
||||||
lineData['line'] = l
|
lineData['line'] = l
|
||||||
@ -46,18 +46,12 @@ def linedata_head_tail ():
|
|||||||
head = head, tail = tail
|
head = head, tail = tail
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
tests = {
|
|
||||||
'linedata:basic': linedata_basic,
|
|
||||||
'linedata:tabs': linedata_tabs,
|
|
||||||
'linedata:head-tail': linedata_head_tail
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
testName = sys.argv[1]
|
testName = sys.argv[1]
|
||||||
test = tests[testName]
|
|
||||||
test()
|
if testName == 'linedata:basic': linedata_basic(' ')
|
||||||
|
if testName == 'linedata:tabs': linedata_basic('\t')
|
||||||
|
if testName == 'linedata:head-tail': linedata_head_tail()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user