rbs 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ module Logger::Period
2
+ def self?.next_rotate_time: (Time now, String shift_age) -> untyped
3
+
4
+ def self?.previous_period_end: (Time now, String shift_age) -> untyped
5
+
6
+ SiD: Integer
7
+ end
@@ -0,0 +1,8 @@
1
+ module Logger::Severity
2
+ DEBUG: 0
3
+ INFO: 1
4
+ WARN: 2
5
+ ERROR: 3
6
+ FATAL: 4
7
+ UNKNOWN: 5
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -41,6 +41,7 @@ files:
41
41
  - docs/stdlib.md
42
42
  - docs/syntax.md
43
43
  - exe/rbs
44
+ - goodcheck.yml
44
45
  - lib/rbs.rb
45
46
  - lib/rbs/ast/annotation.rb
46
47
  - lib/rbs/ast/comment.rb
@@ -57,6 +58,7 @@ files:
57
58
  - lib/rbs/environment_loader.rb
58
59
  - lib/rbs/environment_walker.rb
59
60
  - lib/rbs/errors.rb
61
+ - lib/rbs/factory.rb
60
62
  - lib/rbs/location.rb
61
63
  - lib/rbs/method_type.rb
62
64
  - lib/rbs/namespace.rb
@@ -69,9 +71,10 @@ files:
69
71
  - lib/rbs/test.rb
70
72
  - lib/rbs/test/errors.rb
71
73
  - lib/rbs/test/hook.rb
74
+ - lib/rbs/test/observer.rb
72
75
  - lib/rbs/test/setup.rb
73
76
  - lib/rbs/test/spy.rb
74
- - lib/rbs/test/test_helper.rb
77
+ - lib/rbs/test/tester.rb
75
78
  - lib/rbs/test/type_check.rb
76
79
  - lib/rbs/type_name.rb
77
80
  - lib/rbs/type_name_resolver.rb
@@ -157,6 +160,11 @@ files:
157
160
  - stdlib/find/find.rbs
158
161
  - stdlib/ipaddr/ipaddr.rbs
159
162
  - stdlib/json/json.rbs
163
+ - stdlib/logger/formatter.rbs
164
+ - stdlib/logger/log_device.rbs
165
+ - stdlib/logger/logger.rbs
166
+ - stdlib/logger/period.rbs
167
+ - stdlib/logger/severity.rbs
160
168
  - stdlib/mutex_m/mutex_m.rbs
161
169
  - stdlib/pathname/pathname.rbs
162
170
  - stdlib/prime/integer-extension.rbs
@@ -1,180 +0,0 @@
1
- module RBS
2
- module Test
3
- module TypeAssertions
4
- module ClassMethods
5
- attr_reader :target
6
-
7
- def library(*libs)
8
- @libs = libs
9
- @env = nil
10
- @target = nil
11
- end
12
-
13
- def env
14
- @env ||= begin
15
- loader = RBS::EnvironmentLoader.new
16
- (@libs || []).each do |lib|
17
- loader.add library: lib
18
- end
19
-
20
- RBS::Environment.from_loader(loader).resolve_type_names
21
- end
22
- end
23
-
24
- def builder
25
- @builder ||= DefinitionBuilder.new(env: env)
26
- end
27
-
28
- def testing(type_or_string)
29
- type = case type_or_string
30
- when String
31
- RBS::Parser.parse_type(type_or_string, variables: [])
32
- else
33
- type_or_string
34
- end
35
-
36
- definition = case type
37
- when Types::ClassInstance
38
- builder.build_instance(type.name)
39
- when Types::ClassSingleton
40
- builder.build_singleton(type.name)
41
- else
42
- raise "Test target should be class instance or class singleton: #{type}"
43
- end
44
-
45
- @target = [type, definition]
46
- end
47
- end
48
-
49
- def self.included(base)
50
- base.extend ClassMethods
51
- end
52
-
53
- def env
54
- self.class.env
55
- end
56
-
57
- def builder
58
- self.class.builder
59
- end
60
-
61
- def targets
62
- @targets ||= []
63
- end
64
-
65
- def target
66
- targets.last || self.class.target
67
- end
68
-
69
- def testing(type_or_string)
70
- type = case type_or_string
71
- when String
72
- RBS::Parser.parse_type(type_or_string, variables: [])
73
- else
74
- type_or_string
75
- end
76
-
77
- definition = case type
78
- when Types::ClassInstance
79
- builder.build_instance(type.name)
80
- when Types::ClassSingleton
81
- builder.build_singleton(type.name)
82
- else
83
- raise "Test target should be class instance or class singleton: #{type}"
84
- end
85
-
86
- targets.push [type, definition]
87
-
88
- if block_given?
89
- begin
90
- yield
91
- ensure
92
- targets.pop
93
- end
94
- else
95
- [type, definition]
96
- end
97
- end
98
-
99
- ruby2_keywords def assert_send_type(method_type, receiver, method, *args, &block)
100
- trace = []
101
- spy = Spy.wrap(receiver, method)
102
- spy.callback = -> (result) { trace << result }
103
-
104
- exception = nil
105
-
106
- begin
107
- spy.wrapped_object.__send__(method, *args, &block)
108
- rescue => exn
109
- exception = exn
110
- end
111
-
112
- mt = case method_type
113
- when String
114
- RBS::Parser.parse_method_type(method_type, variables: [])
115
- when RBS::MethodType
116
- method_type
117
- end
118
-
119
- typecheck = TypeCheck.new(self_class: receiver.class, builder: builder)
120
- errors = typecheck.method_call(method, mt, trace.last, errors: [])
121
-
122
- assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }, "Call trace does not match with given method type: #{trace.last.inspect}"
123
-
124
- type, definition = target
125
- method_types = case
126
- when definition.instance_type?
127
- subst = Substitution.build(definition.type_params, type.args)
128
- definition.methods[method].method_types.map do |method_type|
129
- method_type.sub(subst)
130
- end
131
- when definition.class_type?
132
- definition.methods[method].method_types
133
- end
134
-
135
- all_errors = method_types.map {|t| typecheck.method_call(method, t, trace.last, errors: []) }
136
- assert all_errors.any? {|es| es.empty? }, "Call trace does not match one of method definitions:\n #{trace.last.inspect}\n #{method_types.join(" | ")}"
137
-
138
- if exception
139
- raise exception
140
- end
141
- end
142
-
143
- ruby2_keywords def refute_send_type(method_type, receiver, method, *args, &block)
144
- trace = []
145
- spy = Spy.wrap(receiver, method)
146
- spy.callback = -> (result) { trace << result }
147
-
148
- exception = nil
149
- begin
150
- spy.wrapped_object.__send__(method, *args, &block)
151
- rescue Exception => exn
152
- exception = exn
153
- end
154
-
155
- mt = case method_type
156
- when String
157
- RBS::Parser.parse_method_type(method_type, variables: [])
158
- when RBS::MethodType
159
- method_type
160
- end
161
-
162
- mt = mt.update(block: if mt.block
163
- MethodType::Block.new(
164
- type: mt.block.type.with_return_type(Types::Bases::Any.new(location: nil)),
165
- required: mt.block.required
166
- )
167
- end,
168
- type: mt.type.with_return_type(Types::Bases::Any.new(location: nil)))
169
-
170
- typecheck = TypeCheck.new(self_class: receiver.class, builder: builder)
171
- errors = typecheck.method_call(method, mt, trace.last, errors: [])
172
-
173
- assert_operator exception, :is_a?, ::Exception
174
- assert_empty errors.map {|x| RBS::Test::Errors.to_string(x) }
175
-
176
- exception
177
- end
178
- end
179
- end
180
- end