|
5 | 5 | require File.expand_path(File.join(File.dirname(__FILE__) + "/../../lib/cldr/export/deep_validate_keys")) |
6 | 6 |
|
7 | 7 | class TestDeepValidateKeys < Test::Unit::TestCase |
8 | | - test "#paths_match with empty pattern matches only empty key" do |
9 | | - assert DeepValidateKeys.send(:paths_match, [], []) |
10 | | - refute DeepValidateKeys.send(:paths_match, [], ["foo", "bar", "baz", "qux"]) |
| 8 | + test "#paths_match? with empty pattern matches only empty key" do |
| 9 | + assert DeepValidateKeys.send(:"paths_match?", [], []) |
| 10 | + refute DeepValidateKeys.send(:"paths_match?", [], ["foo", "bar", "baz", "qux"]) |
11 | 11 | end |
12 | 12 |
|
13 | | - test "#paths_match matches with exact match" do |
14 | | - assert DeepValidateKeys.send(:paths_match, ["foo", "bar"], ["foo", "bar"]) |
| 13 | + test "#paths_match? matches with exact match" do |
| 14 | + assert DeepValidateKeys.send(:"paths_match?", ["foo", "bar"], ["foo", "bar"]) |
15 | 15 |
|
16 | | - refute DeepValidateKeys.send(:paths_match, ["foo"], ["foo", "bar", "baz", "qux"]) |
17 | | - refute DeepValidateKeys.send(:paths_match, ["foo"], ["bar", "baz", "qux"]) |
18 | | - refute DeepValidateKeys.send(:paths_match, ["foo", "bar"], ["foo"]) |
19 | | - refute DeepValidateKeys.send(:paths_match, ["foo", "baz"], ["foo", "bar", "baz", "qux"]) |
| 16 | + refute DeepValidateKeys.send(:"paths_match?", ["foo"], ["foo", "bar", "baz", "qux"]) |
| 17 | + refute DeepValidateKeys.send(:"paths_match?", ["foo"], ["bar", "baz", "qux"]) |
| 18 | + refute DeepValidateKeys.send(:"paths_match?", ["foo", "bar"], ["foo"]) |
| 19 | + refute DeepValidateKeys.send(:"paths_match?", ["foo", "baz"], ["foo", "bar", "baz", "qux"]) |
20 | 20 | end |
21 | 21 |
|
22 | | - test "#paths_match with . matches single element" do |
23 | | - assert DeepValidateKeys.send(:paths_match, ["foo", ".", "baz"], ["foo", "bar", "baz"]) |
24 | | - assert DeepValidateKeys.send(:paths_match, ["foo", ".", ".", "qux"], ["foo", "bar", "baz", "qux"]) |
25 | | - assert DeepValidateKeys.send(:paths_match, ["."], ["foo"]) |
26 | | - assert DeepValidateKeys.send(:paths_match, [".", "bar"], ["foo", "bar"]) |
| 22 | + test "#paths_match? with . matches single element" do |
| 23 | + assert DeepValidateKeys.send(:"paths_match?", ["foo", ".", "baz"], ["foo", "bar", "baz"]) |
| 24 | + assert DeepValidateKeys.send(:"paths_match?", ["foo", ".", ".", "qux"], ["foo", "bar", "baz", "qux"]) |
| 25 | + assert DeepValidateKeys.send(:"paths_match?", ["."], ["foo"]) |
| 26 | + assert DeepValidateKeys.send(:"paths_match?", [".", "bar"], ["foo", "bar"]) |
27 | 27 |
|
28 | | - refute DeepValidateKeys.send(:paths_match, ["."], []) |
| 28 | + refute DeepValidateKeys.send(:"paths_match?", ["."], []) |
29 | 29 | end |
30 | 30 |
|
31 | | - test "#paths_match with trailing * matches anything after the star" do |
32 | | - assert DeepValidateKeys.send(:paths_match, ["foo", "*"], ["foo", "bar", "baz", "qux"]) |
33 | | - assert DeepValidateKeys.send(:paths_match, ["*"], []) |
34 | | - assert DeepValidateKeys.send(:paths_match, ["*"], ["foo", "bar", "baz", "qux"]) |
| 31 | + test "#paths_match? with trailing * matches anything after the star" do |
| 32 | + assert DeepValidateKeys.send(:"paths_match?", ["foo", "*"], ["foo", "bar", "baz", "qux"]) |
| 33 | + assert DeepValidateKeys.send(:"paths_match?", ["*"], []) |
| 34 | + assert DeepValidateKeys.send(:"paths_match?", ["*"], ["foo", "bar", "baz", "qux"]) |
35 | 35 | end |
36 | 36 |
|
37 | | - test "#paths_match with * greedy matches up to the last match of the next element" do |
38 | | - assert DeepValidateKeys.send(:paths_match, ["foo", "*", "baz", "quxx"], ["foo", "bar", "baz", "qux", "baz", "quxx"]) |
| 37 | + test "#paths_match? with * greedy matches up to the last match of the next element" do |
| 38 | + assert DeepValidateKeys.send(:"paths_match?", ["foo", "*", "baz", "quxx"], ["foo", "bar", "baz", "qux", "baz", "quxx"]) |
39 | 39 |
|
40 | | - refute DeepValidateKeys.send(:paths_match, ["foo", "*", "baz", "quxx"], ["foo", "bar", "baz", "qux"]) |
| 40 | + refute DeepValidateKeys.send(:"paths_match?", ["foo", "*", "baz", "quxx"], ["foo", "bar", "baz", "qux"]) |
41 | 41 | end |
42 | 42 |
|
43 | | - test "#paths_match raise when given a pattern with multiple *" do |
| 43 | + test "#paths_match? raise when given a pattern with multiple *" do |
44 | 44 | exc = assert_raises(NotImplementedError) do |
45 | | - DeepValidateKeys.send(:paths_match, ["foo", "*", "baz", "*"], ["foo", "bar", "baz", "qux", "baz", "quxx"]) |
| 45 | + DeepValidateKeys.send(:"paths_match?", ["foo", "*", "baz", "*"], ["foo", "bar", "baz", "qux", "baz", "quxx"]) |
46 | 46 | end |
47 | 47 | assert_equal "Multiple * in pattern is unsupported", exc.message |
48 | 48 | end |
|
0 commit comments