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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f84252e434574c4818888ea07ea617d1f4766fe
4
- data.tar.gz: 5ff551551c97120833357e2c9efbd614fa2cf8e9
3
+ metadata.gz: 10d2665d5371f256032bbcdfd5c96a2163d041bc
4
+ data.tar.gz: 65fdbde9a0ae188160fba6470f6764fcfa318c63
5
5
  SHA512:
6
- metadata.gz: 61e69948cf64fd5f480f37c7eced6b2d5de22dc9c8e427bff91dea6b0a8d4256185fd52c5c4571adcc3e0712a9dff963ce504d099a84db0b3d2c5b2286736b61
7
- data.tar.gz: f74d5a623f97f109c998335f4427b2af1dcde43da190c019407933c12de62c07c8cc7178e587fd20c602c60c65ce1daa6746ef5bba2d973497dcbbc03baf0b3f
6
+ metadata.gz: 2e41d87dab85fb49248c3482780323b47c743cb2881aca875a64ae5e3dd1fa3b29b0114444b3462bf283ff44f176a982523fb8b410942d7bf04fad952db740be
7
+ data.tar.gz: 4b9c79205f57de7f6737302a76f7545ed664618d5468e7642edc779c9ee6d36dd8c8aaab9080e6dbf9047bf2b758423bfd096ac2e773c852a454e996b968f1fc
@@ -21,6 +21,7 @@ module Delorean
21
21
  split: [String, String],
22
22
  uniq: [Array],
23
23
  sum: [Array],
24
+ transpose: [Array],
24
25
  zip: [Array, [Array, Array, Array]],
25
26
  index: [Array, [Object]],
26
27
  product: [Array, Array],
@@ -500,7 +500,10 @@ eos
500
500
 
501
501
  res += ".select{|#{args_str}| (#{ifexp.ei.rewrite(context)}) }" if
502
502
  defined?(ifexp.ei)
503
- res += ".each_with_object({}){|(#{args_str}), _h#{hid}| " +
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)}
@@ -1,3 +1,3 @@
1
1
  module Delorean
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
@@ -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.8
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-23 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop