finitio 0.7.0.pre.rc2 → 0.7.0.pre.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/finitio/support.rb +1 -0
- data/lib/finitio/support/contract.rb +15 -0
- data/lib/finitio/support/proc_with_code.rb +34 -0
- data/lib/finitio/syntax/type/expression.rb +1 -2
- data/lib/finitio/type/ad_type.rb +13 -0
- data/lib/finitio/version.rb +1 -1
- data/spec/finitio/test_system.rb +4 -1
- data/spec/finitio/with-duplicates.fio +2 -0
- data/spec/support/test_proc_with_code.rb +27 -0
- data/spec/syntax/nodes/test_ad_type.rb +6 -0
- data/spec/syntax/nodes/test_contract.rb +5 -0
- data/spec/syntax/nodes/test_expression.rb +5 -0
- data/spec/syntax/nodes/test_sub_type.rb +5 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bceafae3cf07b42eeafcd42847e29426ee8b9694
|
4
|
+
data.tar.gz: 947dd8fccf1bc29439a8948e18850f7e53f502b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 541944fb0f9e729886145707c46f88c70677a9ea63272021e9fa67d083b867a2ec35c24e1035763c04c21ab8006cccd111717c144c40ed297c06e0b8b6b7ec4a
|
7
|
+
data.tar.gz: 297ce451632080bd09e888c2e16fe1991722485375348ce08b06225c2a15b3f34220a805e05f22fcb623e37aba26e982629c89709b1c643ee8af13f8f63a733e
|
data/Gemfile.lock
CHANGED
data/lib/finitio/support.rb
CHANGED
@@ -29,5 +29,20 @@ module Finitio
|
|
29
29
|
@undresser = clazz.instance_method(:"to_#{name}")
|
30
30
|
end
|
31
31
|
|
32
|
+
def hash
|
33
|
+
[infotype, dresser, undresser].hash
|
34
|
+
end
|
35
|
+
|
36
|
+
def ==(other)
|
37
|
+
super || (
|
38
|
+
other.is_a?(Contract) &&
|
39
|
+
name == other.name &&
|
40
|
+
infotype == other.infotype &&
|
41
|
+
dresser == other.dresser &&
|
42
|
+
undresser == other.undresser
|
43
|
+
)
|
44
|
+
end
|
45
|
+
alias :eql? :==
|
46
|
+
|
32
47
|
end # class Contract
|
33
48
|
end # module Finitio
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Finitio
|
2
|
+
class ProcWithCode < Proc
|
3
|
+
|
4
|
+
def self.new(*args, &bl)
|
5
|
+
return Proc.new(*args, &bl) unless args.size == 2 && bl.nil?
|
6
|
+
|
7
|
+
p = Kernel.eval("->(#{args.first}){ #{args.last} }")
|
8
|
+
p.instance_variable_set(:@_finitio_src, args)
|
9
|
+
|
10
|
+
def p.finitio_src
|
11
|
+
@_finitio_src
|
12
|
+
end
|
13
|
+
|
14
|
+
def p.hash
|
15
|
+
@_finitio_src.hash
|
16
|
+
end
|
17
|
+
|
18
|
+
def p.==(other)
|
19
|
+
super || (
|
20
|
+
other.is_a?(Proc) &&
|
21
|
+
other.respond_to?(:finitio_src) &&
|
22
|
+
other.finitio_src == self.finitio_src
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def p.eql?(other)
|
27
|
+
self.==(other)
|
28
|
+
end
|
29
|
+
|
30
|
+
p
|
31
|
+
end
|
32
|
+
|
33
|
+
end # module ProcWithCode
|
34
|
+
end # module Finitio
|
data/lib/finitio/type/ad_type.rb
CHANGED
@@ -131,5 +131,18 @@ module Finitio
|
|
131
131
|
handler.failed!(self, value, error)
|
132
132
|
end
|
133
133
|
|
134
|
+
def hash
|
135
|
+
[ ruby_type, contracts ].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
def ==(other)
|
139
|
+
super || (
|
140
|
+
other.is_a?(AdType) &&
|
141
|
+
ruby_type == other.ruby_type &&
|
142
|
+
contracts == other.contracts
|
143
|
+
)
|
144
|
+
end
|
145
|
+
alias :eql? :==
|
146
|
+
|
134
147
|
end # class AdType
|
135
148
|
end # module Finitio
|
data/lib/finitio/version.rb
CHANGED
data/spec/finitio/test_system.rb
CHANGED
@@ -30,8 +30,11 @@ describe Finitio, "system" do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
context "feedback about duplicate types" do
|
33
|
+
before {
|
34
|
+
Finitio.stdlib_path(Path.dir.parent)
|
35
|
+
}
|
33
36
|
subject{
|
34
|
-
Finitio.system(Path.dir/"with-duplicates.fio")
|
37
|
+
Finitio.system(Path.dir/"with-duplicates.fio").check_and_warn
|
35
38
|
}
|
36
39
|
|
37
40
|
it{ should be_a(Finitio::System) }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Finitio
|
3
|
+
describe ProcWithCode do
|
4
|
+
|
5
|
+
it 'acts like a proc' do
|
6
|
+
p = ProcWithCode.new{|t| t>0 }
|
7
|
+
expect(p).to be_a(Proc)
|
8
|
+
expect(p.call(2)).to eq(true)
|
9
|
+
expect(p.call(-2)).to eq(false)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'lets compile from source code' do
|
13
|
+
p = ProcWithCode.new("t", "t>0")
|
14
|
+
expect(p).to be_a(Proc)
|
15
|
+
expect(p.call(2)).to eq(true)
|
16
|
+
expect(p.call(-2)).to eq(false)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'yields equal procs for same source code' do
|
20
|
+
p1 = ProcWithCode.new("t", "t>0")
|
21
|
+
p2 = ProcWithCode.new("t", "t>0")
|
22
|
+
expect(p1).to eql(p2)
|
23
|
+
expect(p1.hash).to eql(p2.hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -43,6 +43,7 @@ module Finitio
|
|
43
43
|
]
|
44
44
|
])
|
45
45
|
end
|
46
|
+
|
46
47
|
end
|
47
48
|
|
48
49
|
context 'Two contracts' do
|
@@ -160,6 +161,11 @@ module Finitio
|
|
160
161
|
]
|
161
162
|
])
|
162
163
|
end
|
164
|
+
|
165
|
+
it 'is equal to itself' do
|
166
|
+
j = Syntax.parse(input, root: "ad_type").compile(type_factory)
|
167
|
+
expect(j).to eql(compiled)
|
168
|
+
end
|
163
169
|
end
|
164
170
|
|
165
171
|
end
|
@@ -21,6 +21,11 @@ module Finitio
|
|
21
21
|
expect(compiled.call(12)).to eq(true)
|
22
22
|
expect(compiled.call(9)).to eq(false)
|
23
23
|
end
|
24
|
+
|
25
|
+
it 'is equal to itself' do
|
26
|
+
j = Syntax.parse(input, root: "expression").compile("a")
|
27
|
+
expect(j).to eq(compiled)
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
context '(a >= 10)' do
|
@@ -30,6 +30,11 @@ module Finitio
|
|
30
30
|
[:constraint, "default", [:fn, [:parameters, "i"], [:source, "i >= 0"]]]
|
31
31
|
])
|
32
32
|
end
|
33
|
+
|
34
|
+
it 'is equal to the same type' do
|
35
|
+
j = Syntax.parse(input, root: "sub_type").compile(type_factory)
|
36
|
+
expect(j).to eq(compiled)
|
37
|
+
end
|
33
38
|
end
|
34
39
|
|
35
40
|
context '.Integer( i | positive: i >= 0 )' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.pre.
|
4
|
+
version: 0.7.0.pre.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/finitio/support/dress_helper.rb
|
60
60
|
- lib/finitio/support/heading.rb
|
61
61
|
- lib/finitio/support/metadata.rb
|
62
|
+
- lib/finitio/support/proc_with_code.rb
|
62
63
|
- lib/finitio/support/type_factory.rb
|
63
64
|
- lib/finitio/syntax.rb
|
64
65
|
- lib/finitio/syntax/definitions.rb
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- spec/heading/test_size.rb
|
164
165
|
- spec/heading/test_to_name.rb
|
165
166
|
- spec/spec_helper.rb
|
167
|
+
- spec/support/test_proc_with_code.rb
|
166
168
|
- spec/syntax/expr/test_free_variables.rb
|
167
169
|
- spec/syntax/expr/test_to_proc_source.rb
|
168
170
|
- spec/syntax/nodes/imported.fio
|
@@ -446,6 +448,7 @@ test_files:
|
|
446
448
|
- spec/type/multi_tuple_type/test_include.rb
|
447
449
|
- spec/type/multi_tuple_type/test_default_name.rb
|
448
450
|
- spec/type/multi_tuple_type/test_dress.rb
|
451
|
+
- spec/support/test_proc_with_code.rb
|
449
452
|
- spec/syntax/nodes/test_tuple_type.rb
|
450
453
|
- spec/syntax/nodes/test_set_type.rb
|
451
454
|
- spec/syntax/nodes/test_union_type.rb
|