Mercurial > code > home > repos > light9
changeset 1725:4bc24f91b6f1
fix floatValue cache
Ignore-this: f5e5c6ffef3f48eebd03ecd19fab99b7
author | drewp@bigasterisk.com |
---|---|
date | Thu, 10 May 2018 06:08:39 +0000 |
parents | 49a2a18abe8b |
children | fbe417cb765c |
files | light9/web/graph.coffee light9/web/rdfdb-synced-graph_test.html |
diffstat | 2 files changed, 31 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/graph.coffee Thu May 10 05:29:55 2018 +0000 +++ b/light9/web/graph.coffee Thu May 10 06:08:39 2018 +0000 @@ -266,7 +266,7 @@ switch objs.size when 0 - throw new Error("no value for "+s+" "+p) + throw new Error("no value for "+s.value+" "+p.value) when 1 obj = objs.values().next().value return obj @@ -274,7 +274,7 @@ throw new Error("too many different values: " + JSON.stringify(quads)) floatValue: (s, p) -> - key = s + '|' + p + key = s.value + '|' + p.value hit = @cachedFloatValues.get(key) return hit if hit != undefined #log('float miss', s, p)
--- a/light9/web/rdfdb-synced-graph_test.html Thu May 10 05:29:55 2018 +0000 +++ b/light9/web/rdfdb-synced-graph_test.html Thu May 10 06:08:39 2018 +0000 @@ -27,24 +27,39 @@ const assert = chai.assert; describe("rdfdb-synced-graph", () => { - let elem; - beforeEach(() => { - elem = document.querySelector("#graph"); - window.g = elem; - elem.graph.clearGraph(); - }); - it("makes a node", () => { - assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH"); - }); - it("loads trig", (done) => { - elem.graph.loadTrig(` - @prefix : <http://example.com/> . + let elem, U; + beforeEach(() => { + elem = document.querySelector("#graph"); + window.g = elem; + elem.graph.clearGraph(); + U = elem.graph.Uri.bind(elem.graph); + }); + it("makes a node", () => { + assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH"); + }); + it("loads trig", (done) => { + elem.graph.loadTrig(` + @prefix : <http://light9.bigasterisk.com/> . :a :b :c :d . `, () => { - assert.equal(elem.graph.quads().length, 1); - done(); + assert.equal(elem.graph.quads().length, 1); + done(); }); + }); + describe("floatValue read call", () => { + it("loads two values without confusing them in a cache", (done) => { + elem.graph.loadTrig(` + @prefix : <http://light9.bigasterisk.com/> . + :s :a 1 :g . + :s :b 2 :g . + `, () => { + assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1); + assert.equal(elem.graph.floatValue(U(":s"), U(":b")), 2); + assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1); + done(); + }); }); + }); }); mocha.run(); </script>