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 tests = {
|
||||
'linedata:basic': async () => {
|
||||
const lineData = createLineData('')
|
||||
async function linedata_basic(indent) {
|
||||
const lineData = createLineData('', indent)
|
||||
const next = createStdinReader()
|
||||
|
||||
while ((lineData.line = await next()) != null) {
|
||||
@ -14,18 +12,9 @@ const tests = {
|
||||
const { level, indent, offsetHead, offsetTail, line } = lineData
|
||||
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) {
|
||||
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 () => {
|
||||
async function linedata_head_tail () {
|
||||
const lineData = createLineData('')
|
||||
const next = createStdinReader()
|
||||
|
||||
@ -37,8 +26,8 @@ const tests = {
|
||||
|
||||
console.log(`| head ${head} | tail ${tail} |`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const test = tests[testName]
|
||||
await test()
|
||||
if (testName === 'linedata:basic') await linedata_basic()
|
||||
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 line.rstrip('\n') if len(line) > 0 else None
|
||||
|
||||
def linedata_basic ():
|
||||
lineData = createLineData('')
|
||||
def linedata_basic (indent):
|
||||
lineData = createLineData('', indent)
|
||||
|
||||
while (l := next()) != None:
|
||||
lineData['line'] = l
|
||||
@ -46,18 +46,12 @@ def linedata_head_tail ():
|
||||
head = head, tail = tail
|
||||
))
|
||||
|
||||
|
||||
tests = {
|
||||
'linedata:basic': linedata_basic,
|
||||
'linedata:tabs': linedata_tabs,
|
||||
'linedata:head-tail': linedata_head_tail
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
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__":
|
||||
main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user