delorean_lang 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delorean/base.rb +1 -0
- data/lib/delorean/nodes.rb +4 -1
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d2665d5371f256032bbcdfd5c96a2163d041bc
|
4
|
+
data.tar.gz: 65fdbde9a0ae188160fba6470f6764fcfa318c63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e41d87dab85fb49248c3482780323b47c743cb2881aca875a64ae5e3dd1fa3b29b0114444b3462bf283ff44f176a982523fb8b410942d7bf04fad952db740be
|
7
|
+
data.tar.gz: 4b9c79205f57de7f6737302a76f7545ed664618d5468e7642edc779c9ee6d36dd8c8aaab9080e6dbf9047bf2b758423bfd096ac2e773c852a454e996b968f1fc
|
data/lib/delorean/base.rb
CHANGED
data/lib/delorean/nodes.rb
CHANGED
@@ -500,7 +500,10 @@ eos
|
|
500
500
|
|
501
501
|
res += ".select{|#{args_str}| (#{ifexp.ei.rewrite(context)}) }" if
|
502
502
|
defined?(ifexp.ei)
|
503
|
-
|
503
|
+
|
504
|
+
unpack_str = unpack_vars.count > 1 ? "(#{args_str})" : args_str
|
505
|
+
|
506
|
+
res += ".each_with_object({}){|#{unpack_str}, _h#{hid}| " +
|
504
507
|
"_h#{hid}[#{el.rewrite(context)}]=(#{er.rewrite(context)})}"
|
505
508
|
|
506
509
|
unpack_vars.each {|vname| context.parse_undef_var(vname)}
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -615,8 +615,27 @@ eof
|
|
615
615
|
it "should eval hash comprehension" do
|
616
616
|
engine.parse defn("A:",
|
617
617
|
" b = {i*5 :i for i in [1,2,3]}",
|
618
|
+
" c = [kv for kv in {1:11, 2:22}]",
|
618
619
|
)
|
619
620
|
engine.evaluate("A", "b").should == {5=>1, 10=>2, 15=>3}
|
621
|
+
engine.evaluate("A", "c").should == [[1, 11], [2, 22]]
|
622
|
+
end
|
623
|
+
|
624
|
+
it "for-in-hash should iterate over key/value pairs" do
|
625
|
+
engine.parse defn("A:",
|
626
|
+
" b = {1: 11, 2: 22}",
|
627
|
+
" c = [kv[0]-kv[1] for kv in b]",
|
628
|
+
" d = {kv[0] : kv[1] for kv in b}",
|
629
|
+
" e = [kv for kv in b if kv[1]]",
|
630
|
+
" f = [k-v for k, v in b if k>1]",
|
631
|
+
)
|
632
|
+
engine.evaluate("A", "c").should == [-10, -20]
|
633
|
+
engine.evaluate("A", "d").should == {1=>11, 2=>22}
|
634
|
+
engine.evaluate("A", "f").should == [-20]
|
635
|
+
|
636
|
+
# FIXME: this is a known bug in Delorean caused by the strange way
|
637
|
+
# that select iterates over hashes and provides args to the block.
|
638
|
+
# engine.evaluate("A", "e").should == [[1,11], [2,22]]
|
620
639
|
end
|
621
640
|
|
622
641
|
it "should eval nested hash comprehension" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delorean_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|