diff --git a/light9/web/graph.coffee b/light9/web/graph.coffee
--- a/light9/web/graph.coffee
+++ b/light9/web/graph.coffee
@@ -266,7 +266,7 @@ class window.SyncedGraph
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 @@ class window.SyncedGraph
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)
diff --git a/light9/web/rdfdb-synced-graph_test.html b/light9/web/rdfdb-synced-graph_test.html
--- a/light9/web/rdfdb-synced-graph_test.html
+++ b/light9/web/rdfdb-synced-graph_test.html
@@ -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 : .
+ 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 : .
: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 : .
+ :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();