|
60 | 60 |
|
61 | 61 | context "with specific patterns" do |
62 | 62 | # Note that "01" should not match 1, per data-r2/expr-equal/sameTerm |
63 | | - { |
64 | | - [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
65 | | - [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), nil] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
66 | | - [RDF::URI("http://example.org/xi1"), nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
67 | | - [nil, RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], |
68 | | - [nil, nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], |
69 | | - [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")] => [RDF::Statement.from([RDF::URI("http://example.org/xd1"), RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")])], |
70 | | - }.each do |pattern, result| |
71 | | - pattern = RDF::Query::Pattern.from(pattern) |
| 63 | + patterns = |
| 64 | + { [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
| 65 | + [RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), nil] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
| 66 | + [RDF::URI("http://example.org/xi1"), nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1])], |
| 67 | + [nil, RDF::URI("http://example.org/p"), 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], |
| 68 | + [nil, nil, 1] => [RDF::Statement.from([RDF::URI("http://example.org/xi1"), RDF::URI("http://example.org/p"), 1]), RDF::Statement.from([RDF::URI("http://example.org/xi2"), RDF::URI("http://example.org/p"), 1])], |
| 69 | + [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")] => [RDF::Statement.from([RDF::URI("http://example.org/xd1"), RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")])], |
| 70 | + } |
| 71 | + |
| 72 | + literal_eq_patterns = |
| 73 | + [[nil, RDF::URI("http://example.org/p"), 1], |
| 74 | + [nil, nil, 1], |
| 75 | + [nil, RDF::URI("http://example.org/p"), RDF::Literal::Double.new("1.0e0")]] |
| 76 | + |
| 77 | + patterns.each do |pattern, result| |
72 | 78 | it "returns #{result.inspect} given #{pattern.inspect}" do |
| 79 | + unless subject.supports?(:literal_equality) |
| 80 | + next if literal_eq_patterns.include?(pattern) |
| 81 | + end |
| 82 | + |
| 83 | + pattern = RDF::Query::Pattern.from(pattern) |
73 | 84 | solutions = [] |
| 85 | + |
74 | 86 | subject.send(method, pattern) {|s| solutions << s} |
| 87 | + |
75 | 88 | expect(solutions).to contain_exactly(*result) |
76 | 89 | end |
77 | 90 | end |
|
264 | 277 | end |
265 | 278 |
|
266 | 279 | it 'has two solutions' do |
267 | | - expect(result.count).to eq 2 |
| 280 | + if subject.supports?(:literal_equality) |
| 281 | + expect(result.count).to eq 2 |
| 282 | + end |
268 | 283 | end |
269 | 284 |
|
270 | 285 | it "has xi1 as a solution" do |
|
284 | 299 | end |
285 | 300 |
|
286 | 301 | it 'has one solution' do |
287 | | - expect(result.count).to eq 1 |
| 302 | + if subject.supports?(:literal_equality) |
| 303 | + expect(result.count).to eq 1 |
| 304 | + end |
288 | 305 | end |
289 | 306 |
|
290 | 307 | it "has xd1 as a solution" do |
|
0 commit comments