spec/hash_spec.rb in nydp-0.4.2 vs spec/hash_spec.rb in nydp-0.4.3

- old
+ new

@@ -141,6 +141,28 @@ expect(vm.args.pop).to eq Nydp::NIL end end end + + describe "hash-slice" do + it "returns a new hash containing only the given keys from the old hash" do + hash = Nydp::Hash.new + sfoo = sym "foo" + sbar = sym "bar" + syak = sym "yak" + szeb = sym "zeb" + + h = Nydp::Hash.new + + h[sfoo] = 16 + h[sbar] = 42 + h[szeb] = 99 + + args = [h, pair_list([sbar, syak, szeb])] + + Nydp::Builtin::HashSlice.instance.invoke vm, pair_list(args) + + expect(vm.args.pop).to eq({ sbar => 42, szeb => 99 }) + end + end end