rkwalify 1.4.0.pre.beta → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/workflows/ruby.yml +2 -2
- data/.rubocop.yml +24 -2
- data/.ruby-version +1 -1
- data/Attic/spec/rspec-ex_spec.rb +1 -1
- data/CHANGELOG.md +60 -22
- data/CODE_OF_CONDUCT.md +147 -0
- data/Gemfile.lock +5 -4
- data/README.md +9 -12
- data/ROLL-OUT-STRATEGY.md +5 -4
- data/SECURITY.md +19 -0
- data/bin/kwalify +26 -31
- data/bin/kwalify.rb +26 -31
- data/devbin/README.md +6 -2
- data/{contrib → devbin}/inline-require +1 -1
- data/devbin/mkbig-rkwalify.sh +1 -3
- data/devbin/mktag +2 -2
- data/devbin/rubycheck.sh +39 -0
- data/devbin/run-smoketest.sh +17 -0
- data/devbin/smoke-tests.golden +67 -73
- data/devbin/smoke-tests.sh +23 -20
- data/devbin/update-rel-numbers.sh +3 -3
- data/doc-api/classes/CommandOptionError.html +1 -1
- data/doc-api/classes/Kwalify/Util.html +2 -2
- data/doc-api/classes/Kwalify.html +1 -1
- data/doc-api/files/__/README_txt.html +1 -1
- data/doc-api/files/kwalify/errors_rb.html +1 -1
- data/doc-api/files/kwalify/main_rb.html +1 -1
- data/doc-api/files/kwalify/messages_rb.html +1 -1
- data/doc-api/files/kwalify/meta-validator_rb.html +1 -1
- data/doc-api/files/kwalify/parser/base_rb.html +1 -1
- data/doc-api/files/kwalify/parser/yaml_rb.html +1 -1
- data/doc-api/files/kwalify/rule_rb.html +1 -1
- data/doc-api/files/kwalify/types_rb.html +1 -1
- data/doc-api/files/kwalify/util/assert-text-equal_rb.html +1 -1
- data/doc-api/files/kwalify/util/hash-interface_rb.html +1 -1
- data/doc-api/files/kwalify/util/hashlike_rb.html +1 -1
- data/doc-api/files/kwalify/util/option-parser_rb.html +1 -1
- data/doc-api/files/kwalify/util/ordered-hash_rb.html +1 -1
- data/doc-api/files/kwalify/util/testcase-helper_rb.html +1 -1
- data/doc-api/files/kwalify/util_rb.html +1 -1
- data/doc-api/files/kwalify/validator_rb.html +1 -1
- data/doc-api/files/kwalify/yaml-parser_rb.html +1 -1
- data/doc-api/files/kwalify_rb.html +1 -1
- data/examples/address-book/address-book.schema.yaml +1 -1
- data/examples/invoice/invoice.schema.yaml +1 -1
- data/examples/tapkit/tapkit.schema.yaml +1 -1
- data/lib/kwalify/errors.rb +2 -2
- data/lib/kwalify/main.rb +3 -5
- data/lib/kwalify/messages.rb +1 -1
- data/lib/kwalify/meta-validator.rb +4 -5
- data/lib/kwalify/parser/base.rb +2 -3
- data/lib/kwalify/parser/yaml.rb +5 -5
- data/lib/kwalify/rule.rb +13 -14
- data/lib/kwalify/templates/genclass-java.eruby +1 -1
- data/lib/kwalify/templates/genclass-php.eruby +1 -1
- data/lib/kwalify/templates/genclass-ruby.eruby +1 -1
- data/lib/kwalify/types.rb +1 -1
- data/lib/kwalify/util/assert-text-equal.rb +2 -2
- data/lib/kwalify/util/hash-interface.rb +1 -1
- data/lib/kwalify/util/hashlike.rb +5 -4
- data/lib/kwalify/util/option-parser.rb +1 -1
- data/lib/kwalify/util/ordered-hash.rb +1 -1
- data/lib/kwalify/util/testcase-helper.rb +1 -1
- data/lib/kwalify/util.rb +8 -7
- data/lib/kwalify/validator.rb +38 -13
- data/lib/kwalify/version.rb +1 -1
- data/lib/kwalify/yaml-parser.rb +17 -14
- data/lib/kwalify.rb +26 -1
- data/test/Rookbook.yaml +1 -1
- data/test/data/users-guide/answers-validator.rb +0 -0
- data/test/data/users-guide/validate08.rb +0 -0
- data/test/test-action.rb +1 -1
- data/test/test-action.yaml +1 -1
- data/test/test-databinding.rb +3 -5
- data/test/test-databinding.yaml +1 -1
- data/test/test-hashlike.rb +29 -0
- data/test/test-main.rb +1 -1
- data/test/test-main.yaml +1 -1
- data/test/test-metavalidator.rb +5 -5
- data/test/test-metavalidator.yaml +1 -1
- data/test/test-parser-yaml.rb +5 -5
- data/test/test-parser-yaml.yaml +1 -2
- data/test/test-rule.rb +1 -1
- data/test/test-rule.yaml +1 -2
- data/test/test-users-guide.rb +1 -1
- data/test/test-util.rb +1 -1
- data/test/test-validator.rb +4 -4
- data/test/test-validator.yaml +1 -1
- data/test/test-yaml-parser.rb +3 -3
- data/test/test-yaml-parser.yaml +47 -48
- data/test/test.rb +40 -25
- data/test/test_logger.rb +37 -0
- metadata +11 -6
- data/.rubocop_todo.yml +0 -1369
- data/contrib/kwalify +0 -4167
- /data/{contrib → Attic}/kwalify-0.7.2 +0 -0
- /data/{MIT-LICENSE → MIT-LICENSE.txt} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'kwalify/util/hashlike.rb'
|
|
2
|
+
|
|
3
|
+
class TestHashLike < Test::Unit::TestCase
|
|
4
|
+
class MyClass
|
|
5
|
+
include Kwalify::Util::HashLike
|
|
6
|
+
|
|
7
|
+
attr_accessor :foo, :bar
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_set_and_get
|
|
11
|
+
obj = MyClass.new
|
|
12
|
+
obj[:foo] = 'hello'
|
|
13
|
+
assert_equal 'hello', obj[:foo]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_key_exists
|
|
17
|
+
obj = MyClass.new
|
|
18
|
+
obj[:bar] = 'world'
|
|
19
|
+
assert obj.key?(:bar)
|
|
20
|
+
assert !obj.key?(:missing)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_no_stack_overflow
|
|
24
|
+
# This should NOT cause infinite recursion
|
|
25
|
+
obj = MyClass.new
|
|
26
|
+
100.times { |i| obj[:"key#{i}"] = i }
|
|
27
|
+
assert_equal 50, obj[:key50]
|
|
28
|
+
end
|
|
29
|
+
end
|
data/test/test-main.rb
CHANGED
data/test/test-main.yaml
CHANGED
data/test/test-metavalidator.rb
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
###
|
|
2
2
|
### $Rev$
|
|
3
|
-
### $Release 1.4.0
|
|
3
|
+
### $Release 1.4.0 $
|
|
4
4
|
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
###
|
|
6
|
-
# frozen_string_literal: false
|
|
7
6
|
|
|
8
7
|
require File.dirname(__FILE__) + '/test.rb'
|
|
9
8
|
|
|
@@ -65,12 +64,13 @@ class MetaValidatorTest < Test::Unit::TestCase
|
|
|
65
64
|
end
|
|
66
65
|
expected = @rule_msg
|
|
67
66
|
end
|
|
68
|
-
actual =
|
|
67
|
+
actual = String.new
|
|
69
68
|
errors.each do |error|
|
|
70
69
|
raise error if error.is_a?(Kwalify::AssertionError)
|
|
71
|
-
actual << ("%-20s: [%s] %s\n" % [error.error_symbol.inspect,
|
|
70
|
+
actual << ("%-20s: [%s] %s\n" % [error.error_symbol.inspect,
|
|
71
|
+
error.path, error.message])
|
|
72
72
|
end
|
|
73
|
-
if
|
|
73
|
+
if ENV["DEBUG"]
|
|
74
74
|
print actual
|
|
75
75
|
else
|
|
76
76
|
assert_text_equal(expected, actual)
|
data/test/test-parser-yaml.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
###
|
|
2
2
|
### $Rev$
|
|
3
|
-
### $Release 1.4.0
|
|
3
|
+
### $Release 1.4.0 $
|
|
4
4
|
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
###
|
|
6
6
|
|
|
@@ -21,8 +21,8 @@ class YamlParserTest < Test::Unit::TestCase
|
|
|
21
21
|
@testopts ||= {}
|
|
22
22
|
parser.preceding_alias = true if @testopts['preceding_alias']
|
|
23
23
|
if @error_class
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
_ex = assert_raise(@error_class) do
|
|
25
|
+
_doc = parser.parse(@input)
|
|
26
26
|
end
|
|
27
27
|
else
|
|
28
28
|
doc = parser.parse(@input)
|
|
@@ -33,11 +33,11 @@ class YamlParserTest < Test::Unit::TestCase
|
|
|
33
33
|
else
|
|
34
34
|
actual = doc.inspect + "\n"
|
|
35
35
|
end
|
|
36
|
-
if
|
|
36
|
+
if @logger
|
|
37
37
|
File.write("#{@name}.expected", @expected)
|
|
38
38
|
File.write("#{@name}.actual", actual)
|
|
39
39
|
end
|
|
40
|
-
if
|
|
40
|
+
if ENV["DEBUG"]
|
|
41
41
|
print actual
|
|
42
42
|
else
|
|
43
43
|
assert_text_equal(@expected, actual)
|
data/test/test-parser-yaml.yaml
CHANGED
data/test/test-rule.rb
CHANGED
data/test/test-rule.yaml
CHANGED
data/test/test-users-guide.rb
CHANGED
data/test/test-util.rb
CHANGED
data/test/test-validator.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
###
|
|
2
2
|
### $Rev$
|
|
3
|
-
### $Release 1.4.0
|
|
3
|
+
### $Release 1.4.0 $
|
|
4
4
|
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
###
|
|
6
6
|
|
|
@@ -49,7 +49,7 @@ class ValidatorTest < Test::Unit::TestCase
|
|
|
49
49
|
args = [e.error_symbol.inspect, e.linenum, e.path, e.message]
|
|
50
50
|
actual << ("%-20s: (line %d)[%s] %s\n" % args)
|
|
51
51
|
end
|
|
52
|
-
if
|
|
52
|
+
if ENV["DEBUG"]
|
|
53
53
|
print actual
|
|
54
54
|
else
|
|
55
55
|
assert_text_equal(expected, actual)
|
|
@@ -69,7 +69,7 @@ class ValidatorTest < Test::Unit::TestCase
|
|
|
69
69
|
#actual << "%-20s: (line %d)[%s] %s\n" % args
|
|
70
70
|
actual << ("%-20s: %d:%d:[%s] %s\n" % args)
|
|
71
71
|
end
|
|
72
|
-
if
|
|
72
|
+
if ENV["DEBUG"]
|
|
73
73
|
print actual
|
|
74
74
|
else
|
|
75
75
|
assert_text_equal(expected, actual)
|
|
@@ -84,7 +84,7 @@ class ValidatorTest < Test::Unit::TestCase
|
|
|
84
84
|
actual = error_list.collect { |e|
|
|
85
85
|
"%-20s: [%s] %s\n" % [e.error_symbol.inspect, e.path, e.message]
|
|
86
86
|
}.sort.join()
|
|
87
|
-
if
|
|
87
|
+
if ENV["DEBUG"]
|
|
88
88
|
print actual
|
|
89
89
|
else
|
|
90
90
|
assert_text_equal(expected, actual)
|
data/test/test-validator.yaml
CHANGED
data/test/test-yaml-parser.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
###
|
|
2
2
|
### $Rev$
|
|
3
|
-
### $Release 1.4.0
|
|
3
|
+
### $Release 1.4.0 $
|
|
4
4
|
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
###
|
|
6
6
|
|
|
@@ -32,11 +32,11 @@ class ParserTest < Test::Unit::TestCase
|
|
|
32
32
|
else
|
|
33
33
|
actual = doc.inspect + "\n"
|
|
34
34
|
end
|
|
35
|
-
if
|
|
35
|
+
if @logger
|
|
36
36
|
File.write("#{@name}.expected", @expected)
|
|
37
37
|
File.write("#{@name}.actual", actual)
|
|
38
38
|
end
|
|
39
|
-
if
|
|
39
|
+
if ENV["DEBUG"]
|
|
40
40
|
print actual
|
|
41
41
|
else
|
|
42
42
|
assert_text_equal(@expected, actual)
|
data/test/test-yaml-parser.yaml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##
|
|
2
2
|
## $Rev$
|
|
3
|
-
## $Release 1.4.0
|
|
3
|
+
## $Release 1.4.0 $
|
|
4
4
|
## copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
##
|
|
6
6
|
---
|
|
@@ -151,7 +151,6 @@ input: |
|
|
|
151
151
|
B1:
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
|
|
155
154
|
B1a: 2
|
|
156
155
|
C: 3
|
|
157
156
|
|
|
@@ -299,7 +298,7 @@ input: |
|
|
|
299
298
|
'# comment'
|
|
300
299
|
#
|
|
301
300
|
expected: |
|
|
302
|
-
["A", {"B"=>"# comment"}, "
|
|
301
|
+
["A", {"B"=>"# comment"}, "'"]
|
|
303
302
|
##
|
|
304
303
|
---
|
|
305
304
|
name: comment3
|
|
@@ -348,7 +347,7 @@ input: |
|
|
|
348
347
|
3: [[1, 1], [2, "2"], ['3', 3]]
|
|
349
348
|
#
|
|
350
349
|
expected: |
|
|
351
|
-
{1=>["A", ["B1", "B2"]],
|
|
350
|
+
{"'2'"=>[[["X"]]], 1=>["A", ["B1", "B2"]], 3=>[[1, 1], [2, "2"], ["3", 3]]}
|
|
352
351
|
#expected: |
|
|
353
352
|
# {1=>["A", ["B1", "B2"]],
|
|
354
353
|
# "2"=>[[["X"]]],
|
|
@@ -542,7 +541,7 @@ input: |
|
|
|
542
541
|
ccc
|
|
543
542
|
#
|
|
544
543
|
expected: |
|
|
545
|
-
[{"text1"=>"foo
|
|
544
|
+
[{"text1"=>"foo bar baz"}, {"text2"=>"aaa bbb ccc"}, "foo bar baz", "aaa bbb ccc"]
|
|
546
545
|
##
|
|
547
546
|
---
|
|
548
547
|
name: blocktext02
|
|
@@ -572,7 +571,7 @@ input: |
|
|
|
572
571
|
|
|
573
572
|
#
|
|
574
573
|
expected: |
|
|
575
|
-
[{"text1"=>"A\
|
|
574
|
+
[{"text1"=>"A\nB C"}, {"text2"=>"A\nB C\n\n"}, {"text3"=>"A\nB "}]
|
|
576
575
|
##
|
|
577
576
|
---
|
|
578
577
|
name: blocktext03
|
|
@@ -602,7 +601,7 @@ input: |
|
|
|
602
601
|
|
|
603
602
|
#
|
|
604
603
|
expected: |
|
|
605
|
-
[{"text1"=>" A\n
|
|
604
|
+
[{"text1"=>" A\n B C"}, {"text2"=>" A\n B C\n\n"}, {"text3"=>" A\n B "}]
|
|
606
605
|
##
|
|
607
606
|
---
|
|
608
607
|
name: blocktext04
|
|
@@ -621,7 +620,7 @@ input: |
|
|
|
621
620
|
C
|
|
622
621
|
#
|
|
623
622
|
expected: |
|
|
624
|
-
[{"text1"=>"foo A\
|
|
623
|
+
[{"text1"=>"foo A\nB C"}, "fooA B C"]
|
|
625
624
|
##
|
|
626
625
|
---
|
|
627
626
|
name: blocktext05
|
|
@@ -651,7 +650,7 @@ input: |
|
|
|
651
650
|
|
|
652
651
|
#
|
|
653
652
|
expected: |
|
|
654
|
-
[{"text1"=>"A
|
|
653
|
+
[{"text1"=>"A # B", "text2"=>"# #"}, "A # B", "# #", "x"]
|
|
655
654
|
##
|
|
656
655
|
#---
|
|
657
656
|
#name: blocktext06
|
|
@@ -689,7 +688,7 @@ input: |
|
|
|
689
688
|
ccc
|
|
690
689
|
#
|
|
691
690
|
expected: |
|
|
692
|
-
[{"text1"=>"foo
|
|
691
|
+
[{"text1"=>"foo bar baz"}, {"text2"=>"aaa bbb ccc"}, "foo bar baz", "aaa bbb ccc"]
|
|
693
692
|
##
|
|
694
693
|
---
|
|
695
694
|
name: blocktext12
|
|
@@ -719,7 +718,7 @@ input: |
|
|
|
719
718
|
|
|
720
719
|
#
|
|
721
720
|
expected: |
|
|
722
|
-
[{"text1"=>"A
|
|
721
|
+
[{"text1"=>"A B C"}, {"text2"=>"A B C\n\n"}, {"text3"=>"A B "}]
|
|
723
722
|
##
|
|
724
723
|
---
|
|
725
724
|
name: blocktext13
|
|
@@ -749,8 +748,7 @@ input: |
|
|
|
749
748
|
|
|
750
749
|
#
|
|
751
750
|
expected: |
|
|
752
|
-
[" A
|
|
753
|
-
# [" A\n\n B\n C\n", " A\n\n B\n C\n\n\n", " A\n\n B\n C"]
|
|
751
|
+
[" A B C", " A B C\n\n", " A B "]
|
|
754
752
|
##
|
|
755
753
|
---
|
|
756
754
|
name: blocktext14
|
|
@@ -769,7 +767,7 @@ input: |
|
|
|
769
767
|
C
|
|
770
768
|
#
|
|
771
769
|
expected: |
|
|
772
|
-
[{"text1"=>"foo A
|
|
770
|
+
[{"text1"=>"foo A B C"}, "fooA B C"]
|
|
773
771
|
##
|
|
774
772
|
---
|
|
775
773
|
name: blocktext15
|
|
@@ -799,7 +797,7 @@ input: |
|
|
|
799
797
|
|
|
800
798
|
#
|
|
801
799
|
expected: |
|
|
802
|
-
[{"text1"=>"AA
|
|
800
|
+
[{"text1"=>"AA ## BB", "text2"=>"# #"}, "AA ## BB", "# #", "x"]
|
|
803
801
|
##
|
|
804
802
|
#---
|
|
805
803
|
#name: blocktext16
|
|
@@ -854,7 +852,7 @@ input: |
|
|
|
854
852
|
z: *a1
|
|
855
853
|
#
|
|
856
854
|
expected: |
|
|
857
|
-
[{"A"=>{"x"=>10, "y"=>20, "z"=>{...}}}]
|
|
855
|
+
[{"A" => {"x" => 10, "y" => 20, "z" => {...}}}]
|
|
858
856
|
##
|
|
859
857
|
---
|
|
860
858
|
name: anchor4
|
|
@@ -905,13 +903,13 @@ input: |
|
|
|
905
903
|
#
|
|
906
904
|
expected*:
|
|
907
905
|
ruby: |
|
|
908
|
-
{"
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
"
|
|
914
|
-
|
|
906
|
+
{"type" => "seq",
|
|
907
|
+
"sequence" =>
|
|
908
|
+
[{"type" => "map",
|
|
909
|
+
"mapping" =>
|
|
910
|
+
{"name" => {"type" => "str"},
|
|
911
|
+
"post" => {"type" => "str", "enum" => ["exective", "manager", "clerk"]},
|
|
912
|
+
"supervisor" => {...}}}]}
|
|
915
913
|
java: |
|
|
916
914
|
{"sequence"=>[{"mapping"=>{"name"=>{"type"=>"str"}, "post"=>{"enum"=>["exective", "manager", "clerk"], "type"=>"str"}, "supervisor"=>{...}}, "type"=>"map"}], "type"=>"seq"}
|
|
917
915
|
##
|
|
@@ -941,7 +939,7 @@ input: |
|
|
|
941
939
|
#
|
|
942
940
|
expected*:
|
|
943
941
|
ruby: |
|
|
944
|
-
[{"v"=>[{...}, [...]]}]
|
|
942
|
+
[{"v" => [{...}, [...]]}]
|
|
945
943
|
java: |
|
|
946
944
|
[{"v"=>[{...}, [...]]}]
|
|
947
945
|
##
|
|
@@ -982,12 +980,14 @@ input: |
|
|
|
982
980
|
#
|
|
983
981
|
expected*:
|
|
984
982
|
ruby: |
|
|
985
|
-
{"groups"=>
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
983
|
+
{"groups" =>
|
|
984
|
+
[{"name" => "wheel",
|
|
985
|
+
"owner" => {"name" => "root", "email" => "root@localhost"}},
|
|
986
|
+
{"name" => "users",
|
|
987
|
+
"owner" => {"name" => "user1", "email" => "user1@localhost"}}],
|
|
988
|
+
"users" =>
|
|
989
|
+
[{"name" => "root", "email" => "root@localhost"},
|
|
990
|
+
{"name" => "user1", "email" => "user1@localhost"}]}
|
|
991
991
|
java: |
|
|
992
992
|
##
|
|
993
993
|
---
|
|
@@ -1053,7 +1053,7 @@ input: |
|
|
|
1053
1053
|
bar
|
|
1054
1054
|
#
|
|
1055
1055
|
expected: |
|
|
1056
|
-
["foo
|
|
1056
|
+
["foo ... bar"]
|
|
1057
1057
|
##
|
|
1058
1058
|
---
|
|
1059
1059
|
name: docstart1
|
|
@@ -1094,7 +1094,7 @@ input: |
|
|
|
1094
1094
|
baz
|
|
1095
1095
|
#
|
|
1096
1096
|
expected: |
|
|
1097
|
-
["foo
|
|
1097
|
+
["foo --- bar --- baz"]
|
|
1098
1098
|
##
|
|
1099
1099
|
---
|
|
1100
1100
|
name: default1
|
|
@@ -1148,7 +1148,7 @@ input: |
|
|
|
1148
1148
|
- :sym
|
|
1149
1149
|
expected*:
|
|
1150
1150
|
ruby: |
|
|
1151
|
-
["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "456", #<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)>, :sym]
|
|
1151
|
+
["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "'456'", #<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)>, :sym]
|
|
1152
1152
|
# ruby: |
|
|
1153
1153
|
# ["abc",
|
|
1154
1154
|
# 123,
|
|
@@ -1164,8 +1164,6 @@ expected*:
|
|
|
1164
1164
|
# #<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)>,
|
|
1165
1165
|
# :sym]
|
|
1166
1166
|
java: |
|
|
1167
|
-
["abc", 123, 3.14, true, false, true, false, nil, nil, "123", "456", Tue Feb 01 00:00:00 JST 2005, ":sym"]
|
|
1168
|
-
# ["abc", 123, true, false, true, false, nil, nil, "123", "456", #<Date: 4906743/2,0,2299161>, :sym]
|
|
1169
1167
|
##
|
|
1170
1168
|
---
|
|
1171
1169
|
name: scalar2
|
|
@@ -1189,19 +1187,20 @@ input: |
|
|
|
1189
1187
|
# - 2005-01-01 00:00:00 : 2005-01-01 00:00:00
|
|
1190
1188
|
expected*:
|
|
1191
1189
|
ruby: |
|
|
1192
|
-
[{"abc"=>"ABC"},
|
|
1193
|
-
{123=>123},
|
|
1194
|
-
{3.14=>3.14},
|
|
1195
|
-
{true=>true},
|
|
1196
|
-
{false=>false},
|
|
1197
|
-
{true=>true},
|
|
1198
|
-
{false=>false},
|
|
1199
|
-
{nil=>nil},
|
|
1200
|
-
{nil=>nil},
|
|
1201
|
-
{"123"=>"123"},
|
|
1202
|
-
{"456"=>"456"},
|
|
1203
|
-
{#<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)
|
|
1204
|
-
|
|
1190
|
+
[{"abc" => "ABC"},
|
|
1191
|
+
{123 => 123},
|
|
1192
|
+
{3.14 => 3.14},
|
|
1193
|
+
{true => true},
|
|
1194
|
+
{false => false},
|
|
1195
|
+
{true => true},
|
|
1196
|
+
{false => false},
|
|
1197
|
+
{nil => nil},
|
|
1198
|
+
{nil => nil},
|
|
1199
|
+
{"123" => "123"},
|
|
1200
|
+
{"'456'" => "'456'"},
|
|
1201
|
+
{#<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)> =>
|
|
1202
|
+
#<Date: 2005-01-01 ((2453372j,0s,0n),+0s,2299161j)>},
|
|
1203
|
+
{sym: :sym}]
|
|
1205
1204
|
java: |
|
|
1206
1205
|
[{"abc"=>"ABC"}, {123=>123}, {3.14=>3.14}, {true=>true}, {false=>false}, {true=>true}, {false=>false}, "~ : ~", {nil=>nil}, {"123"=>"123"}, {"456"=>"456"}, {Tue Feb 01 00:00:00 JST 2005=>Tue Feb 01 00:00:00 JST 2005}, {":sym"=>":sym"}]
|
|
1207
1206
|
# {123=>1.23, 3.14=>314, "abc"=>"ABC"}
|
data/test/test.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
###
|
|
2
2
|
### $Rev$
|
|
3
|
-
### $Release 1.4.0
|
|
3
|
+
### $Release 1.4.0 $
|
|
4
4
|
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
|
5
5
|
###
|
|
6
6
|
|
|
@@ -19,25 +19,29 @@ unless defined?(TESTDIR)
|
|
|
19
19
|
$LOAD_PATH << libdir << TESTDIR
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
class StringWriter < String
|
|
24
23
|
alias write <<
|
|
25
24
|
end
|
|
26
25
|
|
|
26
|
+
require "stringio"
|
|
27
|
+
class String
|
|
28
|
+
def winsize
|
|
29
|
+
[24, 80] # or any default terminal size
|
|
30
|
+
end
|
|
31
|
+
end
|
|
27
32
|
|
|
28
33
|
class Hash
|
|
29
34
|
def inspect
|
|
30
|
-
buf = [
|
|
35
|
+
buf = ['{']
|
|
31
36
|
self.keys.sort_by {|k| k.to_s }.each_with_index do |key, i|
|
|
32
|
-
buf << ', ' if i
|
|
37
|
+
buf << ', ' if i.positive?
|
|
33
38
|
buf << key.inspect << '=>' << self[key].inspect
|
|
34
39
|
end
|
|
35
40
|
buf << '}'
|
|
36
|
-
|
|
41
|
+
buf.join
|
|
37
42
|
end
|
|
38
43
|
end
|
|
39
44
|
|
|
40
|
-
|
|
41
45
|
require 'test/unit'
|
|
42
46
|
require 'yaml'
|
|
43
47
|
require 'pp'
|
|
@@ -46,32 +50,43 @@ require 'kwalify/util'
|
|
|
46
50
|
require 'kwalify/util/assert-text-equal'
|
|
47
51
|
require 'kwalify/util/testcase-helper'
|
|
48
52
|
|
|
49
|
-
if $
|
|
53
|
+
if $PROGRAM_NAME == __FILE__
|
|
54
|
+
|
|
55
|
+
# (3 left) 7 tests, 1259 assertions, 3 failures - 99.0826% passed
|
|
56
|
+
# 2/21/2026: 3 failed test (expected a number, got nil).
|
|
57
|
+
# require 'test-parser-yaml'
|
|
58
|
+
|
|
59
|
+
# (6 left) 262 tests, 419 assertions, 6 errors, 0 failures - 97.7099% passed
|
|
60
|
+
# require 'test-action'
|
|
61
|
+
|
|
62
|
+
# (20 left) 277 tests, 445 assertions, 0 failures, 20 errors - 92.7798% passed
|
|
63
|
+
# require 'test-validator'
|
|
64
|
+
|
|
65
|
+
# (30 left) 288 tests, 419 assertions, ..., 29 errors, ...1 notif's - 89.9306% passed
|
|
66
|
+
# require 'test-users-guide'
|
|
67
|
+
|
|
68
|
+
# hidme = <<~HIDME
|
|
69
|
+
require 'test_logger'
|
|
50
70
|
|
|
51
|
-
|
|
71
|
+
require 'test-hashlike'
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
# require 'test-yaml-parser.rb' # 89 tests, 249 assertions, 17 failures, 0 errors
|
|
73
|
+
require 'test-rule'
|
|
55
74
|
|
|
56
|
-
require 'test-
|
|
75
|
+
require 'test-metavalidator'
|
|
57
76
|
|
|
58
|
-
|
|
59
|
-
require 'test-metavalidator.rb'
|
|
77
|
+
require 'test-databinding'
|
|
60
78
|
|
|
61
|
-
|
|
62
|
-
# test_databind4> was redefined [test_databind4(DataBindingTest)]
|
|
63
|
-
# require 'test-databinding.rb'
|
|
79
|
+
require 'test-main'
|
|
64
80
|
|
|
65
|
-
require 'test-
|
|
66
|
-
# require 'test-action.rb' # 22 tests, 26 assertions, 0 failures, 6 ERRORS
|
|
67
|
-
# require 'test-users-guide.rb' # 48 tests, 55 assertions, 29 failures, 0 errors
|
|
81
|
+
require 'test-util'
|
|
68
82
|
|
|
69
|
-
require 'test-
|
|
83
|
+
require 'test-yaml-parser'
|
|
84
|
+
#HIDME
|
|
70
85
|
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
86
|
+
# suite = Test::Unit::TestSuite.new()
|
|
87
|
+
# suite << ValidatorTest.suite()
|
|
88
|
+
# suite << MetaValidatorTest.suite()
|
|
89
|
+
# suite << ParserTest.suite()
|
|
90
|
+
# Test::Unit::UI::Console::TestRunner.run(suite)
|
|
76
91
|
|
|
77
92
|
end
|
data/test/test_logger.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'stringio'
|
|
3
|
+
require 'kwalify/validator'
|
|
4
|
+
|
|
5
|
+
# require 'kwalify'
|
|
6
|
+
# require 'logger'
|
|
7
|
+
|
|
8
|
+
class TestLogger < Test::Unit::TestCase
|
|
9
|
+
def test_custom_logger
|
|
10
|
+
output = StringIO.new
|
|
11
|
+
custom_logger = Logger.new(output)
|
|
12
|
+
|
|
13
|
+
schema = {
|
|
14
|
+
'type' => 'map',
|
|
15
|
+
'mapping' => {
|
|
16
|
+
'*' => { 'type' => 'any' }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
validator = Kwalify::Validator.new(schema, logger: custom_logger)
|
|
20
|
+
|
|
21
|
+
# Should accept the custom logger
|
|
22
|
+
assert_equal custom_logger, validator.logger
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_default_logger
|
|
26
|
+
schema = {
|
|
27
|
+
'type' => 'map',
|
|
28
|
+
'mapping' => {
|
|
29
|
+
'*' => { 'type' => 'any' }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
validator = Kwalify::Validator.new(schema)
|
|
33
|
+
|
|
34
|
+
# Should use default logger
|
|
35
|
+
assert_not_nil validator.logger
|
|
36
|
+
end
|
|
37
|
+
end
|