Skip to content

Commit fecb2f5

Browse files
committed
Fix or mark pending some regular-expression tests.
1 parent 828569f commit fecb2f5

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

lib/sparql/algebra/operator/regex.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,19 @@ def apply(text, pattern, flags = RDF::Literal(''), **options)
5656
flags = flags.to_s
5757
# TODO: validate flag syntax
5858

59+
# 's' mode in XPath is like ruby MUTLILINE
60+
# 'm' mode in XPath is like ruby /^$/ vs /\A\z/
61+
unless flags.include?(?m)
62+
pattern = '\A' + pattern[1..-1] if pattern.start_with?('^')
63+
pattern = pattern[0..-2] + '\z' if pattern.end_with?('$')
64+
end
65+
5966
options = 0
60-
raise NotImplementedError, "unsupported regular expression flag: /s" if flags.include?(?s) # FIXME
61-
options |= Regexp::MULTILINE if flags.include?(?m)
67+
%w(q x).each do |flag|
68+
raise NotImplementedError, "unsupported regular expression flag: /#{flag}" if flags.include?(flag) # FIXME
69+
end
70+
options |= Regexp::MULTILINE if flags.include?(?s) # dot-all mode
6271
options |= Regexp::IGNORECASE if flags.include?(?i)
63-
options |= Regexp::EXTENDED if flags.include?(?x)
6472
RDF::Literal(Regexp.new(pattern, options) === text)
6573
end
6674

script/tc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ def run_tc(tc, **options)
9898
info = "More compact representation"
9999
when /syntax-update-(26|27|28|36).ru/
100100
info = "Whitespace in string tokens"
101+
when 'graph-empty', 'graph-exist', 'graph-not-exist'
102+
info = "Graphs with empty BGP"
103+
when 'REGEX with the q option'
104+
info = "REGEX flag q – no meta-characters"
105+
when 'REGEX with the ignore spacing (x) option', 'REGEX with the ignore spacing (x) option with class expression'
106+
info = "REGEX flag x – remove whitespace"
101107
else
102108
case tc.name
103109
when 'date-1', 'expr-5.rq'
@@ -268,21 +274,16 @@ def run_tc(tc, **options)
268274
STDERR.puts "unknown test type #{tc.type}"
269275
end
270276
end
271-
STDERR.puts options[:logger].to_s if options[:logger].level <= Logger::INFO
272277
rescue Interrupt
273278
exit(1)
274279
rescue Exception => e
275280
result = 'exception'
276281
unless options[:quiet]
277282
STDERR.puts(" Exception: #{e.message}")
278-
if options[:verbose]
279-
STDERR.puts e.backtrace
280-
STDERR.puts options[:logger].to_s
281-
else
282-
STDERR.puts options[:logger].to_s #if options[:logger].level <= Logger::INFO
283-
end
283+
STDERR.puts e.backtrace if options[:verbose]
284284
end
285285
ensure
286+
STDERR.puts options[:logger].to_s if options[:logger].level <= Logger::INFO
286287
options[:results][result] ||= 0
287288
options[:results][result] += 1
288289

spec/suite_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,13 @@ def self.sparql_11_tests
226226
end
227227

228228
def self.sparql_12_tests
229-
%w(grouping syntax-escaping syntax-triple-terms-negative syntax-triple-terms-positive).map do |partial|
229+
%w(grouping
230+
syntax-triple-terms-negative
231+
syntax-triple-terms-positive
232+
eval-triple-terms
233+
lang-basedir
234+
rdf11
235+
).map do |partial|
230236
"#{BASE}sparql12/#{partial}/manifest.ttl"
231237
end
232238
end

spec/suite_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
pending "failed when simplifying whitespace in terminals"
3636
when 'nps_inverse.rq', 'nps_direct_and_inverse.rq'
3737
pending("New SPARQL tests")
38+
when 'graph-empty.rq', 'graph-empty-exist.rq', 'graph-empty-not-exist.rq'
39+
pending("Graphs with empty BGP")
40+
when 'regex-no-metacharacters.rq', 'regex-no-metacharacters-case-insensitive.rq'
41+
pending("REGEX flag q – no meta-characters")
42+
when 'regex-ignore-whitespaces.rq', 'regex-ignore-whitespaces-class-expression.rq'
43+
pending("REGEX flag x – remove whitespace")
3844
end
3945

4046
skip 'Entailment Regimes' if t.entailment?
@@ -71,6 +77,7 @@
7177
base_uri: t.base_uri,
7278
form: t.form,
7379
all_vars: true,
80+
optimize: true,
7481
logger: t.logger)
7582

7683
expect(result).to describe_csv_solutions(t.solutions)
@@ -110,6 +117,7 @@
110117
base_uri: t.base_uri,
111118
all_vars: true,
112119
form: t.form,
120+
optimize: true,
113121
logger: t.logger)
114122

115123
expect(result).to describe_solutions(t.expected, t)

0 commit comments

Comments
 (0)