@daikonjs/nearley
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@daikonjs/nearley", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Nearley syntax definitions for Daikon.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -127,4 +127,9 @@ import { parseExpression } from "./expressions.js"; | ||
}); | ||
// expect(await parseExpression('get "a" in "rain"')).toStrictEqual([1]); | ||
// expect(await parseExpression('get /a/g in "rain"')).toStrictEqual([1]); | ||
expect(await parseExpression('get "a" in "rain"')).toStrictEqual([1]); | ||
expect( | ||
await parseExpression('get /a/ in "rain on my parade"') | ||
).toStrictEqual([1]); | ||
expect( | ||
await parseExpression('get /a/g in "rain on my parade"') | ||
).toStrictEqual([1, 12, 14]); | ||
expect(await parseExpression('indexOf "t" "this is a test"')).toStrictEqual( | ||
@@ -359,2 +364,54 @@ { | ||
}); | ||
it("should parse boolean expressions", async () => { | ||
// Equality | ||
expect(await parseExpression("true == false")).toStrictEqual({ | ||
type: "boolean", | ||
value: false, | ||
}); | ||
expect(await parseExpression("true != false")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
expect(await parseExpression("true == true")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
expect(await parseExpression("true != true")).toStrictEqual({ | ||
type: "boolean", | ||
value: false, | ||
}); | ||
// Logical operators | ||
expect(await parseExpression("true && false")).toStrictEqual({ | ||
type: "boolean", | ||
value: false, | ||
}); | ||
expect(await parseExpression("true || false")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
expect(await parseExpression("true && true")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
expect(await parseExpression("true || true")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
expect(await parseExpression("false && false")).toStrictEqual({ | ||
type: "boolean", | ||
value: false, | ||
}); | ||
expect(await parseExpression("false || false")).toStrictEqual({ | ||
type: "boolean", | ||
value: false, | ||
}); | ||
// Inversion | ||
expect(await parseExpression("true == !false")).toStrictEqual({ | ||
type: "boolean", | ||
value: true, | ||
}); | ||
}); | ||
}); |
@@ -6,2 +6,10 @@ // @ts-ignore | ||
it("debug", () => { | ||
expect( | ||
parseValues('urls[]=url("https://pastebin.com/raw/Na2Hmfm8")') | ||
).toStrictEqual({ | ||
slug: "urls[]", | ||
type: "url", | ||
value: "https://pastebin.com/raw/Na2Hmfm8", | ||
}); | ||
expect(parseValues('hello="world"')).toStrictEqual({ | ||
@@ -22,2 +30,7 @@ slug: "hello", | ||
}); | ||
expect(parseValues("test[]=2")).toStrictEqual({ | ||
type: "number", | ||
slug: "test[]", | ||
value: 2, | ||
}); | ||
expect(parseValues("test ='world'")).toStrictEqual({ | ||
@@ -43,2 +56,32 @@ type: "string", | ||
}); | ||
expect(parseValues('test=url("https://elk.wtf")')).toStrictEqual({ | ||
type: "url", | ||
slug: "test", | ||
value: "https://elk.wtf", | ||
}); | ||
expect(parseValues('test=path("./config.daikon")')).toStrictEqual({ | ||
type: "path", | ||
slug: "test", | ||
value: "./config.daikon", | ||
}); | ||
expect(parseValues("test=string(2)")).toStrictEqual({ | ||
type: "string", | ||
slug: "test", | ||
value: "2", | ||
}); | ||
expect(parseValues("test=boolean(1)")).toStrictEqual({ | ||
type: "boolean", | ||
slug: "test", | ||
value: true, | ||
}); | ||
expect(parseValues("test=boolean(0)")).toStrictEqual({ | ||
type: "boolean", | ||
slug: "test", | ||
value: false, | ||
}); | ||
expect(parseValues('test=number("2")')).toStrictEqual({ | ||
type: "number", | ||
slug: "test", | ||
value: 2, | ||
}); | ||
expect(parseValues("test=fn.add 1 2")).toStrictEqual({ | ||
@@ -45,0 +88,0 @@ type: "function", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173216
2613
1