diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb10225..26c5eabb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Fixed a bug where box fill colours would cover box text, and changed the implementation of `hide` style option. - Removed double quotes when rendering objects of type `None`. +- Removed double quotes when rendering objects that are not of type `str`. ### 📚 Documentation and demo website changes diff --git a/memory-viz/src/memory_model.ts b/memory-viz/src/memory_model.ts index 8e16f44b..dd270410 100644 --- a/memory-viz/src/memory_model.ts +++ b/memory-viz/src/memory_model.ts @@ -223,10 +223,10 @@ export class MemoryModel { let display_text; if (type === "bool") { display_text = value ? "True" : "False"; - } else if (type === "None") { - display_text = "None"; - } else { + } else if (type === "str") { display_text = JSON.stringify(value); + } else { + display_text = String(value); } if (value !== null && value !== undefined) { diff --git a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap index 9630e030..1c768b07 100644 --- a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap +++ b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap @@ -76,4 +76,6 @@ exports[`draw function renders diagrams with provided roughjs_config 'fill' opti exports[`draw function renders diagrams with provided roughjs_config 'roughness' option 1`] = `""hello"id42str"`; +exports[`draw function renders range object 1`] = `"range(1, 5)id42range"`; + exports[`draw function should produce consistent svg when provided seed 1`] = `"lst1id82lst2id84pid99did10tid11__main__"David is cool!"id19str7id13int"`; diff --git a/memory-viz/src/tests/draw.spec.tsx b/memory-viz/src/tests/draw.spec.tsx index 3731a8e9..40aebe13 100644 --- a/memory-viz/src/tests/draw.spec.tsx +++ b/memory-viz/src/tests/draw.spec.tsx @@ -749,4 +749,20 @@ describe("draw function", () => { const svg: String = m.serializeSVG(); expect(svg).toMatchSnapshot(); }); + + it("renders range object", () => { + const objects: Array = [ + { + type: "range", + id: 42, + value: "range(1, 5)", + }, + ]; + const m: InstanceType = draw(objects, true, { + width: 1300, + roughjs_config: { options: { seed: 12345 } }, + }); + const svg: String = m.serializeSVG(); + expect(svg).toMatchSnapshot(); + }); });