sorbet-coerce 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5eefb63dc137b65889fa5dd16b05fcf3bef550474d7f7f175746ccca96e640d
4
- data.tar.gz: 0ca052e76b580d9979d24444b8bee8d564a49c6d2162acd36469fbd205cb6354
3
+ metadata.gz: f794cd6c92bb1d7e6481a4fb26b9073ac278f8e3bb379f835333128053f251d6
4
+ data.tar.gz: 5013d33d3021f8da6784c7dfa8ff1014d40791d201a6a2b5c41ca31c64968454
5
5
  SHA512:
6
- metadata.gz: afb06e4b35972579d9ff0ffb0d9eb48c1de7465911b0f56a07a1d7dcda528f70d525834f5ac81c300394132ae5e8fec7d614814c900710778fa13296ed2db7f3
7
- data.tar.gz: eecba6f2089a944984b2e6ba595ad21bbff2d11bb3fc56d38532fff94f029fe6beac3e1fce25272d46162e893d3040a548fe4240058db8a258900ee815acb946
6
+ metadata.gz: f605e6bc1e70dd0bb913cc12fec39d6b171768ff031ad3e67ad0917404fc0c27058c6dc7d15e75e8e2fac38727f3e68a9d48372e40c4ef4cc4d430e4a617dc91
7
+ data.tar.gz: a8f8e5d9d3ebdb9b9766e6dbf338e8bb7abf8a5dbf551721904f8e8083a4adad7471164e0a52c0a1cc7c846d19e9b5f1709a6f01916637867374cecd1a190f7a
@@ -6,8 +6,8 @@ module T
6
6
 
7
7
  Elem = type_member
8
8
 
9
- sig { params(args: T.untyped, raise_value_error: T.nilable(T::Boolean)).returns(Elem) }
10
- def from(args, raise_value_error: nil); end
9
+ sig { params(args: T.untyped, raise_coercion_error: T.nilable(T::Boolean)).returns(Elem) }
10
+ def from(args, raise_coercion_error: nil); end
11
11
  end
12
12
 
13
13
  module Private
@@ -0,0 +1,22 @@
1
+ # typed: true
2
+ require 'sorbet-coerce'
3
+
4
+ T.assert_type!(T::Coerce[Integer].new.from('1'), Integer)
5
+ T.assert_type!(
6
+ T::Coerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false),
7
+ T.nilable(Integer),
8
+ )
9
+
10
+ T::Coerce::Configuration.raise_coercion_error = true
11
+ coercion_error = nil
12
+ begin
13
+ T::Coerce[T.nilable(Integer)].new.from('invalid')
14
+ rescue T::Coerce::CoercionError => e
15
+ coercion_error = e
16
+ end
17
+ raise 'no coercion error is raised' unless coercion_error
18
+
19
+ T.assert_type!(
20
+ T::Coerce[T.nilable(Integer)].new.from('invalid', raise_coercion_error: false),
21
+ T.nilable(Integer),
22
+ )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-coerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chan Zuckerberg Initiative
@@ -125,6 +125,7 @@ files:
125
125
  - spec/coerce_spec.rb
126
126
  - spec/nested_spec.rb
127
127
  - spec/soft_error_spec.rb
128
+ - spec/sorbet_test_cases.rb
128
129
  - spec/spec_helper.rb
129
130
  homepage: https://github.com/chanzuckerberg/sorbet-coerce
130
131
  licenses: