|
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 |
|
85 | 98 | expect(solutions.size).to eq @statements.size |
86 | 99 | end |
87 | 100 |
|
88 | | - it "returns statements from unnamed graphs with false graph_name" do |
89 | | - pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false) |
90 | | - solutions = [] |
91 | | - subject.send(method, pattern) {|s| solutions << s} |
92 | | - |
93 | | - named_statements = subject.statements |
94 | | - named_statements.reject! {|st| st.has_name?} unless |
95 | | - subject.respond_to?(:graph_name) && !subject.graph_name.nil? |
96 | | - |
97 | | - expect(solutions.size).to eq named_statements.size |
98 | | - end |
99 | | - |
100 | 101 | it "returns statements from named graphs with variable graph_name" do |
101 | 102 | unless subject.graph_names.to_a.empty? |
102 | 103 | pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: :c) |
|
276 | 277 | end |
277 | 278 |
|
278 | 279 | it 'has two solutions' do |
279 | | - expect(result.count).to eq 2 |
| 280 | + if subject.supports?(:literal_equality) |
| 281 | + expect(result.count).to eq 2 |
| 282 | + end |
280 | 283 | end |
281 | 284 |
|
282 | 285 | it "has xi1 as a solution" do |
|
296 | 299 | end |
297 | 300 |
|
298 | 301 | it 'has one solution' do |
299 | | - expect(result.count).to eq 1 |
| 302 | + if subject.supports?(:literal_equality) |
| 303 | + expect(result.count).to eq 1 |
| 304 | + end |
300 | 305 | end |
301 | 306 |
|
302 | 307 | it "has xd1 as a solution" do |
|
314 | 319 | before { skip unless subject.respond_to?(:query_execute, true ) } |
315 | 320 |
|
316 | 321 | it "defines a protected #query_execute method" do |
317 | | - expect(subject.class.protected_method_defined?(:query_execute)) |
318 | | - .to be_truthy |
| 322 | + expect(subject.protected_methods).to include :query_execute |
319 | 323 | end |
320 | 324 |
|
321 | 325 | include_examples 'query execution', :query_execute |
|
327 | 331 | before { skip unless subject.respond_to?(:query_pattern, true ) } |
328 | 332 |
|
329 | 333 | it "defines a protected #query_pattern method" do |
330 | | - expect(subject.class.protected_method_defined?(:query_pattern)).to be_truthy |
| 334 | + expect(subject.protected_methods).to include :query_pattern |
331 | 335 | end |
332 | 336 |
|
333 | 337 | include_examples 'query pattern', :query_pattern |
|
0 commit comments