dont use short Desc - close umuro/squiggle#51
This commit is contained in:
parent
05b5efce18
commit
a95cdfabe3
|
@ -9,12 +9,12 @@ let expectParseToBe = (expr, answer) =>
|
|||
|
||||
let testParse = (expr, answer) => test(expr, () => expectParseToBe(expr, answer))
|
||||
|
||||
let testDescParse = (desc, expr, answer) => test(desc, () => expectParseToBe(expr, answer))
|
||||
let testDescriptionParse = (desc, expr, answer) => test(desc, () => expectParseToBe(expr, answer))
|
||||
|
||||
module MySkip = {
|
||||
let testParse = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer))
|
||||
|
||||
let testDescParse = (desc, expr, answer) => Skip.test(desc, () => expectParseToBe(expr, answer))
|
||||
let testDescriptionParse = (desc, expr, answer) => Skip.test(desc, () => expectParseToBe(expr, answer))
|
||||
}
|
||||
|
||||
describe("MathJs parse", () => {
|
||||
|
@ -44,23 +44,23 @@ describe("MathJs parse", () => {
|
|||
})
|
||||
|
||||
describe("arrays", () => {
|
||||
testDescParse("empty", "[]", "[]")
|
||||
testDescParse("define", "[0, 1, 2]", "[0, 1, 2]")
|
||||
testDescParse("define with strings", "['hello', 'world']", "['hello', 'world']")
|
||||
testDescriptionParse("empty", "[]", "[]")
|
||||
testDescriptionParse("define", "[0, 1, 2]", "[0, 1, 2]")
|
||||
testDescriptionParse("define with strings", "['hello', 'world']", "['hello', 'world']")
|
||||
MySkip.testParse("range(0, 4)", "range(0, 4)")
|
||||
testDescParse("index", "([0,1,2])[1]", "([0, 1, 2])[1]")
|
||||
testDescriptionParse("index", "([0,1,2])[1]", "([0, 1, 2])[1]")
|
||||
})
|
||||
|
||||
describe("records", () => {
|
||||
testDescParse("define", "{a: 1, b: 2}", "{a: 1, b: 2}")
|
||||
testDescParse("use", "record.property", "record['property']")
|
||||
testDescriptionParse("define", "{a: 1, b: 2}", "{a: 1, b: 2}")
|
||||
testDescriptionParse("use", "record.property", "record['property']")
|
||||
})
|
||||
|
||||
describe("comments", () => {
|
||||
MySkip.testDescParse("define", "# This is a comment", "???")
|
||||
MySkip.testDescriptionParse("define", "# This is a comment", "???")
|
||||
})
|
||||
|
||||
describe("if statement", () => { // TODO Tertiary operator instead
|
||||
MySkip.testDescParse("define", "if (true) { 1 } else { 0 }", "???")
|
||||
MySkip.testDescriptionParse("define", "if (true) { 1 } else { 0 }", "???")
|
||||
})
|
||||
})
|
||||
|
|
|
@ -3,11 +3,11 @@ open Reducer_TestHelpers
|
|||
|
||||
let testParseToBe = (expr, answer) => test(expr, () => expectParseToBe(expr, answer))
|
||||
|
||||
let testDescParseToBe = (desc, expr, answer) => test(desc, () => expectParseToBe(expr, answer))
|
||||
let testDescriptionParseToBe = (desc, expr, answer) => test(desc, () => expectParseToBe(expr, answer))
|
||||
|
||||
let testEvalToBe = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer))
|
||||
|
||||
let testDescEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer))
|
||||
let testDescriptionEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer))
|
||||
|
||||
describe("reducer using mathjs parse", () => {
|
||||
// Test the MathJs parser compatibility
|
||||
|
@ -29,14 +29,14 @@ describe("reducer using mathjs parse", () => {
|
|||
//Note. () is a empty list in Lisp
|
||||
// The only builtin structure in Lisp is list. There are no arrays
|
||||
// [1,2,3] becomes (1 2 3)
|
||||
testDescParseToBe("empty", "[]", "Ok(())")
|
||||
testDescriptionParseToBe("empty", "[]", "Ok(())")
|
||||
testParseToBe("[1, 2, 3]", "Ok((1 2 3))")
|
||||
testParseToBe("['hello', 'world']", "Ok(('hello' 'world'))")
|
||||
testDescParseToBe("index", "([0,1,2])[1]", "Ok((:$atIndex (0 1 2) (1)))")
|
||||
testDescriptionParseToBe("index", "([0,1,2])[1]", "Ok((:$atIndex (0 1 2) (1)))")
|
||||
})
|
||||
describe("records", () => {
|
||||
testDescParseToBe("define", "{a: 1, b: 2}", "Ok((:$constructRecord (('a' 1) ('b' 2))))")
|
||||
testDescParseToBe(
|
||||
testDescriptionParseToBe("define", "{a: 1, b: 2}", "Ok((:$constructRecord (('a' 1) ('b' 2))))")
|
||||
testDescriptionParseToBe(
|
||||
"use",
|
||||
"{a: 1, b: 2}.a",
|
||||
"Ok((:$atIndex (:$constructRecord (('a' 1) ('b' 2))) ('a')))",
|
||||
|
@ -73,7 +73,7 @@ describe("eval", () => {
|
|||
testEvalToBe("[1, 2, 3]", "Ok([1, 2, 3])")
|
||||
testEvalToBe("['hello', 'world']", "Ok(['hello', 'world'])")
|
||||
testEvalToBe("([0,1,2])[1]", "Ok(1)")
|
||||
testDescEvalToBe("index not found", "([0,1,2])[10]", "Error(Array index not found: 10)")
|
||||
testDescriptionEvalToBe("index not found", "([0,1,2])[10]", "Error(Array index not found: 10)")
|
||||
})
|
||||
describe("records", () => {
|
||||
test("define", () => expectEvalToBe("{a: 1, b: 2}", "Ok({a: 1, b: 2})"))
|
||||
|
@ -96,10 +96,10 @@ describe("eval", () => {
|
|||
})
|
||||
|
||||
describe("test exceptions", () => {
|
||||
testDescEvalToBe(
|
||||
testDescriptionEvalToBe(
|
||||
"javascript exception",
|
||||
"javascriptraise('div by 0')",
|
||||
"Error(JS Exception: Error: 'div by 0')",
|
||||
)
|
||||
testDescEvalToBe("rescript exception", "rescriptraise()", "Error(TODO: unhandled rescript exception)")
|
||||
testDescriptionEvalToBe("rescript exception", "rescriptraise()", "Error(TODO: unhandled rescript exception)")
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user