bson 4.1.1 → 5.2.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 +5 -5
- data/README.md +106 -7
- data/Rakefile +86 -43
- data/ext/bson/{native-endian.h → bson-endian.h} +14 -107
- data/ext/bson/bson-native.h +135 -0
- data/ext/bson/bytebuf.c +133 -0
- data/ext/bson/endian.c +117 -0
- data/ext/bson/extconf.rb +8 -3
- data/ext/bson/init.c +364 -0
- data/ext/bson/libbson-utf8.c +230 -0
- data/ext/bson/read.c +470 -0
- data/ext/bson/util.c +250 -0
- data/ext/bson/write.c +675 -0
- data/lib/bson/active_support.rb +19 -0
- data/lib/bson/array.rb +97 -30
- data/lib/bson/big_decimal.rb +77 -0
- data/lib/bson/binary.rb +510 -70
- data/lib/bson/boolean.rb +15 -4
- data/lib/bson/code.rb +25 -12
- data/lib/bson/code_with_scope.rb +41 -15
- data/lib/bson/config.rb +3 -28
- data/lib/bson/date.rb +16 -4
- data/lib/bson/date_time.rb +6 -4
- data/lib/bson/db_pointer.rb +110 -0
- data/lib/bson/dbref.rb +154 -0
- data/lib/bson/decimal128/builder.rb +456 -0
- data/lib/bson/decimal128.rb +272 -0
- data/lib/bson/document.rb +177 -7
- data/lib/bson/environment.rb +17 -2
- data/lib/bson/error/bson_decode_error.rb +11 -0
- data/lib/bson/error/ext_json_parse_error.rb +11 -0
- data/lib/bson/error/illegal_key.rb +23 -0
- data/lib/bson/error/invalid_binary_type.rb +37 -0
- data/lib/bson/error/invalid_dbref_argument.rb +12 -0
- data/lib/bson/error/invalid_decimal128_argument.rb +25 -0
- data/lib/bson/error/invalid_decimal128_range.rb +27 -0
- data/lib/bson/error/invalid_decimal128_string.rb +26 -0
- data/lib/bson/error/invalid_key.rb +24 -0
- data/lib/bson/error/invalid_object_id.rb +11 -0
- data/lib/bson/error/invalid_regexp_pattern.rb +13 -0
- data/lib/bson/error/unrepresentable_precision.rb +19 -0
- data/lib/bson/error/unserializable_class.rb +13 -0
- data/lib/bson/error/unsupported_binary_subtype.rb +12 -0
- data/lib/bson/error/unsupported_type.rb +11 -0
- data/lib/bson/error.rb +22 -0
- data/lib/bson/ext_json.rb +389 -0
- data/lib/bson/false_class.rb +6 -4
- data/lib/bson/float.rb +43 -7
- data/lib/bson/hash.rb +152 -37
- data/lib/bson/int32.rb +104 -6
- data/lib/bson/int64.rb +111 -8
- data/lib/bson/integer.rb +43 -9
- data/lib/bson/json.rb +3 -1
- data/lib/bson/max_key.rb +21 -10
- data/lib/bson/min_key.rb +21 -10
- data/lib/bson/nil_class.rb +7 -3
- data/lib/bson/object.rb +25 -17
- data/lib/bson/object_id.rb +98 -113
- data/lib/bson/open_struct.rb +59 -0
- data/lib/bson/regexp.rb +129 -56
- data/lib/bson/registry.rb +7 -10
- data/lib/bson/specialized.rb +8 -4
- data/lib/bson/string.rb +12 -32
- data/lib/bson/symbol.rb +107 -11
- data/lib/bson/time.rb +68 -7
- data/lib/bson/time_with_zone.rb +67 -0
- data/lib/bson/timestamp.rb +50 -10
- data/lib/bson/true_class.rb +6 -4
- data/lib/bson/undefined.rb +28 -2
- data/lib/bson/vector.rb +44 -0
- data/lib/bson/version.rb +6 -14
- data/lib/bson.rb +22 -12
- data/spec/README.md +14 -0
- data/spec/bson/array_spec.rb +38 -62
- data/spec/bson/big_decimal_spec.rb +328 -0
- data/spec/bson/binary_spec.rb +199 -53
- data/spec/bson/binary_uuid_spec.rb +190 -0
- data/spec/bson/boolean_spec.rb +2 -1
- data/spec/bson/byte_buffer_read_spec.rb +198 -0
- data/spec/bson/byte_buffer_spec.rb +122 -381
- data/spec/bson/byte_buffer_write_spec.rb +855 -0
- data/spec/bson/code_spec.rb +6 -4
- data/spec/bson/code_with_scope_spec.rb +6 -4
- data/spec/bson/config_spec.rb +1 -35
- data/spec/bson/date_spec.rb +2 -1
- data/spec/bson/date_time_spec.rb +55 -1
- data/spec/bson/dbref_legacy_spec.rb +186 -0
- data/spec/bson/dbref_spec.rb +487 -0
- data/spec/bson/decimal128_spec.rb +1840 -0
- data/spec/bson/document_as_spec.rb +61 -0
- data/spec/bson/document_spec.rb +205 -32
- data/spec/bson/ext_json_parse_spec.rb +346 -0
- data/spec/bson/false_class_spec.rb +9 -1
- data/spec/bson/float_spec.rb +42 -1
- data/spec/bson/hash_as_spec.rb +58 -0
- data/spec/bson/hash_spec.rb +318 -66
- data/spec/bson/int32_spec.rb +248 -1
- data/spec/bson/int64_spec.rb +308 -1
- data/spec/bson/integer_spec.rb +61 -3
- data/spec/bson/json_spec.rb +2 -1
- data/spec/bson/max_key_spec.rb +6 -4
- data/spec/bson/min_key_spec.rb +6 -4
- data/spec/bson/nil_class_spec.rb +2 -1
- data/spec/bson/object_id_spec.rb +95 -5
- data/spec/bson/object_spec.rb +3 -2
- data/spec/bson/open_struct_spec.rb +87 -0
- data/spec/bson/raw_spec.rb +594 -0
- data/spec/bson/regexp_spec.rb +61 -8
- data/spec/bson/registry_spec.rb +3 -2
- data/spec/bson/string_spec.rb +26 -33
- data/spec/bson/symbol_raw_spec.rb +70 -0
- data/spec/bson/symbol_spec.rb +77 -20
- data/spec/bson/time_spec.rb +206 -2
- data/spec/bson/time_with_zone_spec.rb +69 -0
- data/spec/bson/timestamp_spec.rb +58 -2
- data/spec/bson/true_class_spec.rb +9 -1
- data/spec/bson/undefined_spec.rb +28 -1
- data/spec/bson/vector_spec.rb +33 -0
- data/spec/bson_spec.rb +2 -1
- data/spec/runners/binary_vector.rb +78 -0
- data/spec/runners/common_driver.rb +348 -0
- data/spec/runners/corpus.rb +191 -0
- data/spec/runners/corpus_legacy.rb +248 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +231 -0
- data/spec/shared/lib/mrss/constraints.rb +378 -0
- data/spec/shared/lib/mrss/docker_runner.rb +298 -0
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +210 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +238 -0
- data/spec/shared/lib/mrss/release/candidate.rb +281 -0
- data/spec/shared/lib/mrss/release/product_data.rb +144 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +113 -0
- data/spec/shared/lib/mrss/session_registry.rb +69 -0
- data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +37 -0
- data/spec/shared/lib/tasks/candidate.rake +64 -0
- data/spec/shared/share/Dockerfile.erb +251 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/config.sh +27 -0
- data/spec/shared/shlib/distro.sh +84 -0
- data/spec/shared/shlib/server.sh +423 -0
- data/spec/shared/shlib/set_env.sh +110 -0
- data/spec/spec_helper.rb +61 -1
- data/spec/spec_tests/binary_vector_spec.rb +82 -0
- data/spec/spec_tests/common_driver_spec.rb +84 -0
- data/spec/spec_tests/corpus_legacy_spec.rb +72 -0
- data/spec/spec_tests/corpus_spec.rb +134 -0
- data/spec/spec_tests/data/binary_vector/README.md +61 -0
- data/spec/spec_tests/data/binary_vector/float32.json +65 -0
- data/spec/spec_tests/data/binary_vector/int8.json +57 -0
- data/spec/spec_tests/data/binary_vector/packed_bit.json +83 -0
- data/spec/spec_tests/data/corpus/README.md +15 -0
- data/spec/spec_tests/data/corpus/array.json +49 -0
- data/spec/spec_tests/data/corpus/binary.json +153 -0
- data/spec/spec_tests/data/corpus/boolean.json +27 -0
- data/spec/spec_tests/data/corpus/code.json +67 -0
- data/spec/spec_tests/data/corpus/code_w_scope.json +78 -0
- data/spec/spec_tests/data/corpus/datetime.json +42 -0
- data/spec/spec_tests/data/corpus/dbpointer.json +56 -0
- data/spec/spec_tests/data/corpus/dbref.json +51 -0
- data/spec/spec_tests/data/corpus/decimal128-1.json +317 -0
- data/spec/spec_tests/data/corpus/decimal128-2.json +793 -0
- data/spec/spec_tests/data/corpus/decimal128-3.json +1771 -0
- data/spec/spec_tests/data/corpus/decimal128-4.json +165 -0
- data/spec/spec_tests/data/corpus/decimal128-5.json +402 -0
- data/spec/spec_tests/data/corpus/decimal128-6.json +131 -0
- data/spec/spec_tests/data/corpus/decimal128-7.json +327 -0
- data/spec/spec_tests/data/corpus/document.json +60 -0
- data/spec/spec_tests/data/corpus/double.json +87 -0
- data/spec/spec_tests/data/corpus/int32.json +43 -0
- data/spec/spec_tests/data/corpus/int64.json +43 -0
- data/spec/spec_tests/data/corpus/maxkey.json +12 -0
- data/spec/spec_tests/data/corpus/minkey.json +12 -0
- data/spec/spec_tests/data/corpus/multi-type-deprecated.json +15 -0
- data/spec/spec_tests/data/corpus/multi-type.json +11 -0
- data/spec/spec_tests/data/corpus/null.json +12 -0
- data/spec/spec_tests/data/corpus/oid.json +28 -0
- data/spec/spec_tests/data/corpus/regex.json +65 -0
- data/spec/spec_tests/data/corpus/string.json +72 -0
- data/spec/spec_tests/data/corpus/symbol.json +80 -0
- data/spec/spec_tests/data/corpus/timestamp.json +34 -0
- data/spec/spec_tests/data/corpus/top.json +262 -0
- data/spec/spec_tests/data/corpus/undefined.json +15 -0
- data/spec/spec_tests/data/corpus_legacy/array.json +49 -0
- data/spec/spec_tests/data/corpus_legacy/binary.json +69 -0
- data/spec/spec_tests/data/corpus_legacy/boolean.json +27 -0
- data/spec/spec_tests/data/corpus_legacy/code.json +67 -0
- data/spec/spec_tests/data/corpus_legacy/code_w_scope.json +78 -0
- data/spec/spec_tests/data/corpus_legacy/document.json +36 -0
- data/spec/spec_tests/data/corpus_legacy/double.json +69 -0
- data/spec/spec_tests/data/corpus_legacy/failures/datetime.json +31 -0
- data/spec/spec_tests/data/corpus_legacy/failures/dbpointer.json +42 -0
- data/spec/spec_tests/data/corpus_legacy/failures/int64.json +38 -0
- data/spec/spec_tests/data/corpus_legacy/failures/symbol.json +62 -0
- data/spec/spec_tests/data/corpus_legacy/int32.json +38 -0
- data/spec/spec_tests/data/corpus_legacy/maxkey.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/minkey.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/null.json +12 -0
- data/spec/spec_tests/data/corpus_legacy/oid.json +28 -0
- data/spec/spec_tests/data/corpus_legacy/regex.json +37 -0
- data/spec/spec_tests/data/corpus_legacy/string.json +67 -0
- data/spec/spec_tests/data/corpus_legacy/timestamp.json +18 -0
- data/spec/spec_tests/data/corpus_legacy/top.json +62 -0
- data/spec/spec_tests/data/corpus_legacy/undefined.json +13 -0
- data/spec/spec_tests/data/decimal128/decimal128-1.json +363 -0
- data/spec/spec_tests/data/decimal128/decimal128-2.json +793 -0
- data/spec/spec_tests/data/decimal128/decimal128-3.json +1771 -0
- data/spec/spec_tests/data/decimal128/decimal128-4.json +165 -0
- data/spec/spec_tests/data/decimal128/decimal128-5.json +402 -0
- data/spec/spec_tests/data/decimal128/decimal128-6.json +131 -0
- data/spec/spec_tests/data/decimal128/decimal128-7.json +327 -0
- data/spec/support/shared_examples.rb +32 -11
- data/spec/support/spec_config.rb +17 -0
- data/spec/support/utils.rb +58 -0
- metadata +284 -45
- checksums.yaml.gz.sig +0 -3
- data/ext/bson/native.c +0 -722
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Decimal128",
|
|
3
|
+
"bson_type": "0x13",
|
|
4
|
+
"test_key": "d",
|
|
5
|
+
"parseErrors": [
|
|
6
|
+
{
|
|
7
|
+
"description": "Incomplete Exponent",
|
|
8
|
+
"subject": "1e"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"description": "Exponent at the beginning",
|
|
12
|
+
"subject": "E01"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"description": "Just a decimal place",
|
|
16
|
+
"subject": "."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"description": "2 decimal places",
|
|
20
|
+
"subject": "..3"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"description": "2 decimal places",
|
|
24
|
+
"subject": ".13.3"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"description": "2 decimal places",
|
|
28
|
+
"subject": "1..3"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"description": "2 decimal places",
|
|
32
|
+
"subject": "1.3.4"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"description": "2 decimal places",
|
|
36
|
+
"subject": "1.34."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"description": "Decimal with no digits",
|
|
40
|
+
"subject": ".e"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"description": "2 signs",
|
|
44
|
+
"subject": "+-32.4"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"description": "2 signs",
|
|
48
|
+
"subject": "-+32.4"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"description": "2 negative signs",
|
|
52
|
+
"subject": "--32.4"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"description": "2 negative signs",
|
|
56
|
+
"subject": "-32.-4"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"description": "End in negative sign",
|
|
60
|
+
"subject": "32.0-"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"description": "2 negative signs",
|
|
64
|
+
"subject": "32.4E--21"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"description": "2 negative signs",
|
|
68
|
+
"subject": "32.4E-2-1"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"description": "2 signs",
|
|
72
|
+
"subject": "32.4E+-21"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"description": "Empty string",
|
|
76
|
+
"subject": ""
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"description": "leading white space positive number",
|
|
80
|
+
"subject": " 1"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"description": "leading white space negative number",
|
|
84
|
+
"subject": " -1"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"description": "trailing white space",
|
|
88
|
+
"subject": "1 "
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"description": "Invalid",
|
|
92
|
+
"subject": "E"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"description": "Invalid",
|
|
96
|
+
"subject": "invalid"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"description": "Invalid",
|
|
100
|
+
"subject": "i"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"description": "Invalid",
|
|
104
|
+
"subject": "in"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"description": "Invalid",
|
|
108
|
+
"subject": "-in"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"description": "Invalid",
|
|
112
|
+
"subject": "Na"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"description": "Invalid",
|
|
116
|
+
"subject": "-Na"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"description": "Invalid",
|
|
120
|
+
"subject": "1.23abc"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"description": "Invalid",
|
|
124
|
+
"subject": "1.23abcE+02"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"description": "Invalid",
|
|
128
|
+
"subject": "1.23E+0aabs2"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Decimal128",
|
|
3
|
+
"bson_type": "0x13",
|
|
4
|
+
"test_key": "d",
|
|
5
|
+
"parseErrors": [
|
|
6
|
+
{
|
|
7
|
+
"description": "[basx572] Near-specials (Conversion_syntax)",
|
|
8
|
+
"subject": "-9Inf"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"description": "[basx516] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
12
|
+
"subject": "-1-"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"description": "[basx533] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
16
|
+
"subject": "0000.."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"description": "[basx534] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
20
|
+
"subject": ".0000."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"description": "[basx535] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
24
|
+
"subject": "00..00"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"description": "[basx569] Near-specials (Conversion_syntax)",
|
|
28
|
+
"subject": "0Inf"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"description": "[basx571] Near-specials (Conversion_syntax)",
|
|
32
|
+
"subject": "-0Inf"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"description": "[basx575] Near-specials (Conversion_syntax)",
|
|
36
|
+
"subject": "0sNaN"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"description": "[basx503] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
40
|
+
"subject": "++1"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"description": "[basx504] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
44
|
+
"subject": "--1"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"description": "[basx505] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
48
|
+
"subject": "-+1"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"description": "[basx506] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
52
|
+
"subject": "+-1"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"description": "[basx510] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
56
|
+
"subject": " +1"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"description": "[basx513] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
60
|
+
"subject": " + 1"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"description": "[basx514] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
64
|
+
"subject": " - 1"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"description": "[basx501] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
68
|
+
"subject": "."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"description": "[basx502] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
72
|
+
"subject": ".."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"description": "[basx519] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
76
|
+
"subject": ""
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"description": "[basx525] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
80
|
+
"subject": "e100"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"description": "[basx549] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
84
|
+
"subject": "e+1"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"description": "[basx577] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
88
|
+
"subject": ".e+1"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"description": "[basx578] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
92
|
+
"subject": "+.e+1"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"description": "[basx581] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
96
|
+
"subject": "E+1"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"description": "[basx582] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
100
|
+
"subject": ".E+1"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"description": "[basx583] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
104
|
+
"subject": "+.E+1"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"description": "[basx579] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
108
|
+
"subject": "-.e+"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"description": "[basx580] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
112
|
+
"subject": "-.e"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"description": "[basx584] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
116
|
+
"subject": "-.E+"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"description": "[basx585] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
120
|
+
"subject": "-.E"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"description": "[basx589] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
124
|
+
"subject": "+.Inf"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"description": "[basx586] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
128
|
+
"subject": ".NaN"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"description": "[basx587] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
132
|
+
"subject": "-.NaN"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"description": "[basx545] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
136
|
+
"subject": "ONE"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"description": "[basx561] Near-specials (Conversion_syntax)",
|
|
140
|
+
"subject": "qNaN"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"description": "[basx573] Near-specials (Conversion_syntax)",
|
|
144
|
+
"subject": "-sNa"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"description": "[basx588] some baddies with dots and Es and dots and specials (Conversion_syntax)",
|
|
148
|
+
"subject": "+.sNaN"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"description": "[basx544] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
152
|
+
"subject": "ten"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"description": "[basx527] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
156
|
+
"subject": "u0b65"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"description": "[basx526] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
160
|
+
"subject": "u0e5a"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"description": "[basx515] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
164
|
+
"subject": "x"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"description": "[basx574] Near-specials (Conversion_syntax)",
|
|
168
|
+
"subject": "xNaN"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"description": "[basx530] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
172
|
+
"subject": ".123.5"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"description": "[basx500] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
176
|
+
"subject": "1..2"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"description": "[basx542] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
180
|
+
"subject": "1e1.0"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"description": "[basx553] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
184
|
+
"subject": "1E+1.2.3"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"description": "[basx543] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
188
|
+
"subject": "1e123e"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"description": "[basx552] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
192
|
+
"subject": "1E+1.2"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"description": "[basx546] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
196
|
+
"subject": "1e.1"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"description": "[basx547] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
200
|
+
"subject": "1e1."
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"description": "[basx554] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
204
|
+
"subject": "1E++1"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"description": "[basx555] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
208
|
+
"subject": "1E--1"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"description": "[basx556] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
212
|
+
"subject": "1E+-1"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"description": "[basx557] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
216
|
+
"subject": "1E-+1"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"description": "[basx558] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
220
|
+
"subject": "1E'1"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"description": "[basx559] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
224
|
+
"subject": "1E\"1"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"description": "[basx520] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
228
|
+
"subject": "1e-"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"description": "[basx560] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
232
|
+
"subject": "1E"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"description": "[basx548] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
236
|
+
"subject": "1ee"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"description": "[basx551] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
240
|
+
"subject": "1.2.1"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"description": "[basx550] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
244
|
+
"subject": "1.23.4"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"description": "[basx529] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
248
|
+
"subject": "1.34.5"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"description": "[basx531] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
252
|
+
"subject": "01.35."
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"description": "[basx532] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
256
|
+
"subject": "01.35-"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"description": "[basx518] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
260
|
+
"subject": "3+"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"description": "[basx521] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
264
|
+
"subject": "7e99999a"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"description": "[basx570] Near-specials (Conversion_syntax)",
|
|
268
|
+
"subject": "9Inf"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"description": "[basx512] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
272
|
+
"subject": "12 "
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"description": "[basx517] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
276
|
+
"subject": "12-"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"description": "[basx507] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
280
|
+
"subject": "12e"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"description": "[basx508] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
284
|
+
"subject": "12e++"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"description": "[basx509] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
288
|
+
"subject": "12f4"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"description": "[basx536] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
292
|
+
"subject": "111e*123"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"description": "[basx537] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
296
|
+
"subject": "111e123-"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"description": "[basx540] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
300
|
+
"subject": "111e1*23"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"description": "[basx538] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
304
|
+
"subject": "111e+12+"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"description": "[basx539] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
308
|
+
"subject": "111e1-3-"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"description": "[basx541] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
312
|
+
"subject": "111E1e+3"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"description": "[basx528] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
316
|
+
"subject": "123,65"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"description": "[basx523] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
320
|
+
"subject": "7e12356789012x"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"description": "[basx522] The 'baddies' tests from DiagBigDecimal, plus some new ones (Conversion_syntax)",
|
|
324
|
+
"subject": "7e123567890x"
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rubocop:todo all
|
|
2
|
+
# Copyright (C) 2009-2020 MongoDB Inc.
|
|
2
3
|
#
|
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,10 +19,8 @@ shared_examples_for "a binary encoded string" do
|
|
|
18
19
|
Encoding.find(BSON::BINARY)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(encoded.encoding).to eq(binary_encoding)
|
|
24
|
-
end
|
|
22
|
+
it "returns the string with binary encoding" do
|
|
23
|
+
expect(encoded.encoding).to eq(binary_encoding)
|
|
25
24
|
end
|
|
26
25
|
end
|
|
27
26
|
|
|
@@ -50,7 +49,7 @@ shared_examples_for "a deserializable bson element" do
|
|
|
50
49
|
end
|
|
51
50
|
|
|
52
51
|
let(:result) do
|
|
53
|
-
described_class.from_bson(io)
|
|
52
|
+
(defined?(klass) ? klass : described_class).from_bson(io)
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
it "deserializes from bson" do
|
|
@@ -65,6 +64,28 @@ shared_examples_for "a JSON serializable object" do
|
|
|
65
64
|
end
|
|
66
65
|
end
|
|
67
66
|
|
|
67
|
+
shared_examples_for "an Extended JSON serializable object" do
|
|
68
|
+
|
|
69
|
+
it "serializes the Extended JSON from #as_extended_json" do
|
|
70
|
+
expect(object.to_extended_json).to eq(object.as_extended_json.to_json)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
shared_examples_for '#as_extended_json returns self' do
|
|
75
|
+
|
|
76
|
+
it 'returns self' do
|
|
77
|
+
expect(object.as_extended_json).to eq(object)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
shared_examples_for '#as_json calls #as_extended_json' do
|
|
82
|
+
|
|
83
|
+
it 'calls #as_extended_json' do
|
|
84
|
+
expect(object).to receive(:as_extended_json).with(no_args)
|
|
85
|
+
object.as_json
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
68
89
|
shared_examples_for "immutable when frozen" do |block|
|
|
69
90
|
|
|
70
91
|
context "when the document is frozen" do
|
|
@@ -124,7 +145,7 @@ shared_examples_for "a validated BSON key" do
|
|
|
124
145
|
end
|
|
125
146
|
end
|
|
126
147
|
|
|
127
|
-
context "when the string
|
|
148
|
+
context "when the string has dots/dollars" do
|
|
128
149
|
|
|
129
150
|
context "when the string starts with $" do
|
|
130
151
|
|
|
@@ -132,10 +153,10 @@ shared_examples_for "a validated BSON key" do
|
|
|
132
153
|
"$testing"
|
|
133
154
|
end
|
|
134
155
|
|
|
135
|
-
it "
|
|
156
|
+
it "does not raise an exception" do
|
|
136
157
|
expect {
|
|
137
158
|
validated
|
|
138
|
-
}.
|
|
159
|
+
}.to_not raise_error
|
|
139
160
|
end
|
|
140
161
|
end
|
|
141
162
|
|
|
@@ -145,10 +166,10 @@ shared_examples_for "a validated BSON key" do
|
|
|
145
166
|
"testing.testing"
|
|
146
167
|
end
|
|
147
168
|
|
|
148
|
-
it "
|
|
169
|
+
it "does not raise an exception" do
|
|
149
170
|
expect {
|
|
150
171
|
validated
|
|
151
|
-
}.
|
|
172
|
+
}.to_not raise_error
|
|
152
173
|
end
|
|
153
174
|
end
|
|
154
175
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# rubocop:todo all
|
|
2
|
+
require 'singleton'
|
|
3
|
+
|
|
4
|
+
class SpecConfig
|
|
5
|
+
include Singleton
|
|
6
|
+
|
|
7
|
+
COMPACTION_CHANCE = 0.001
|
|
8
|
+
|
|
9
|
+
def active_support?
|
|
10
|
+
%w(1 true yes).include?(ENV['WITH_ACTIVE_SUPPORT']) ||
|
|
11
|
+
ENV['WITH_ACTIVE_SUPPORT'] =~ /[0-9]/ && ENV['WITH_ACTIVE_SUPPORT'] != '0'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def compact?
|
|
15
|
+
%w(1 true yes).include?(ENV['COMPACT'])
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# rubocop:todo all
|
|
2
|
+
module Utils
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
# JRuby chokes when strings like "\xfe\x00\xff", which are not valid UTF-8,
|
|
6
|
+
# appear in the source. Use this method to build such strings.
|
|
7
|
+
# char_array is an array of byte values to use for the string.
|
|
8
|
+
def make_byte_string(char_array, encoding = 'BINARY')
|
|
9
|
+
char_array.map do |char|
|
|
10
|
+
char.chr.force_encoding('BINARY')
|
|
11
|
+
end.join.force_encoding(encoding)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Forks the current process and executes the given block in the child.
|
|
15
|
+
# The value returned by the block is then returned in the parent process
|
|
16
|
+
# by this method.
|
|
17
|
+
#
|
|
18
|
+
# @return [ Object ] the value returned by the block
|
|
19
|
+
def perform_in_child(&block)
|
|
20
|
+
reader, writer = IO.pipe
|
|
21
|
+
|
|
22
|
+
if fork
|
|
23
|
+
parent_worker(reader, writer)
|
|
24
|
+
else
|
|
25
|
+
child_worker(reader, writer, &block)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# A utility method for #perform_in_child, to handle tasks for the parent
|
|
32
|
+
# side of the fork.
|
|
33
|
+
#
|
|
34
|
+
# @param [ IO ] reader The reader IO for the pipe
|
|
35
|
+
# @param [ IO ] writer The writer IO for the pipe
|
|
36
|
+
#
|
|
37
|
+
# @return [ Object ] the value returned by the child process
|
|
38
|
+
def parent_worker(reader, writer)
|
|
39
|
+
writer.close
|
|
40
|
+
blob = reader.read
|
|
41
|
+
reader.close
|
|
42
|
+
Process.wait
|
|
43
|
+
Marshal.load(blob)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# A utility method for #perform_in_child, to handle tasks for the child
|
|
47
|
+
# side of the fork.
|
|
48
|
+
#
|
|
49
|
+
# @param [ IO ] reader The reader IO for the pipe
|
|
50
|
+
# @param [ IO ] writer The writer IO for the pipe
|
|
51
|
+
def child_worker(reader, writer, &block)
|
|
52
|
+
reader.close
|
|
53
|
+
result = block.call
|
|
54
|
+
writer.write Marshal.dump(result)
|
|
55
|
+
writer.close
|
|
56
|
+
exit! 0
|
|
57
|
+
end
|
|
58
|
+
end
|