-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2988 from quantified-uncertainty/decorated-statem…
…ents-fixes Find "Find in editor" and value tooltips for decorated statements
- Loading branch information
Showing
22 changed files
with
194 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@quri/squiggle-lang": patch | ||
"@quri/squiggle-components": patch | ||
--- | ||
|
||
Fixes error with "Find in editor" and tooltips not working for decorated values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ReactNode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
export function reactAsDom(node: ReactNode): { dom: HTMLDivElement } { | ||
const dom = document.createElement("div"); | ||
const root = createRoot(dom); | ||
root.render(node); | ||
// This is compatible with `CompletionInfo` and `TooltipView` CodeMirror types | ||
return { dom }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { testRun } from "../helpers/helpers.js"; | ||
|
||
describe("SqValue.asJS", () => { | ||
test("SqDict -> Map", async () => { | ||
const value = ( | ||
await testRun('{ x: 5, y: [3, "foo", { dist: normal(5,2) } ] }') | ||
).result.asJS(); | ||
|
||
expect(value).toBeInstanceOf(Object); | ||
}); | ||
|
||
test("Dict fields", async () => { | ||
const value = (await testRun("{ x: 5 }")).result.asJS(); | ||
|
||
expect((value as any).value.x).toBe(5); | ||
}); | ||
|
||
test("Deeply nested dist", async () => { | ||
const value = ( | ||
await testRun('{ x: 5, y: [3, "foo", { dist: normal(5,2) } ] }') | ||
).result.asJS(); | ||
|
||
expect((value as any).value.y[2].value.dist).toBeInstanceOf(Array); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { nodeToString } from "../../src/ast/parse.js"; | ||
import { assertTag, testRun } from "../helpers/helpers.js"; | ||
|
||
describe("SqValueContext", () => { | ||
test("valueAst for nested nodes", async () => { | ||
const { bindings } = await testRun(` | ||
x = { foo: 5 } | ||
y = 6 | ||
`); | ||
|
||
const x = bindings.get("x"); | ||
assertTag(x, "Dict"); | ||
expect(nodeToString(x.context!.valueAst)).toBe( | ||
"(LetStatement :x (Block (Dict (KeyValue 'foo' 5))))" | ||
); | ||
expect(x.context?.valueAstIsPrecise).toBe(true); | ||
|
||
const foo = x.value.get("foo"); | ||
expect(nodeToString(foo!.context!.valueAst)).toBe("(KeyValue 'foo' 5)"); | ||
expect(foo!.context!.valueAstIsPrecise).toBe(true); | ||
|
||
const y = bindings.get("y"); | ||
assertTag(y, "Number"); | ||
|
||
expect(nodeToString(y.context!.valueAst)).toBe( | ||
"(LetStatement :y (Block 6))" | ||
); | ||
expect(y!.context!.valueAstIsPrecise).toBe(true); | ||
}); | ||
|
||
test("valueAst for decorated statements", async () => { | ||
const { bindings } = await testRun(` | ||
@name("Z") | ||
z = 5 | ||
`); | ||
|
||
const z = bindings.get("z"); | ||
assertTag(z, "Number"); | ||
|
||
expect(nodeToString(z.context!.valueAst)).toBe( | ||
"(LetStatement :z (Block 5))" | ||
); | ||
}); | ||
}); |
25 changes: 0 additions & 25 deletions
25
...gle-lang/__tests__/public/SqValue_test.ts → ...-lang/__tests__/SqValue/docstring_test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
524e387
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
quri-hub – ./packages/hub
squigglehub.org
squiggle-hub.org
squigglehub.com
www.squiggle-hub.com
quri-hub-git-main-quantified-uncertainty.vercel.app
squiggle-hub.com
quri-hub-quantified-uncertainty.vercel.app
www.squigglehub.com
www.squiggle-hub.org
www.squigglehub.org
524e387
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
squiggle-website – ./packages/website
www.squiggle-language.com
squiggle-language.com
squiggle-website-git-main-quantified-uncertainty.vercel.app
squiggle-website-quantified-uncertainty.vercel.app
preview.squiggle-language.com