Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass test 68.
Implement key and value methods on the thing returned from the hash iterator.
  • Loading branch information
pmurias committed Sep 17, 2014
1 parent 820163d commit ea1190b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/vm/js/bin/run_tests
@@ -1,5 +1,5 @@
#!/bin/bash
# 19 and 30 where moved out as they were parrot specific, 52,54 is missing, we can't pass 49 till we are bootstraped
#echo 'No tests pass as we are in the early stages of a rewrite/refactor'
prove -e './nqp-js-with-setting' t/nqp/{01..08}* t/nqp/{10,11,13,14,15,16,17,20,23,40,41,42,48,81,83}* t/js/getcomp-js.t
prove -e './nqp-js-with-setting' t/nqp/{01..08}* t/nqp/{10,11,13,14,15,16,17,20,23,40,41,42,48,68,81,83}* t/js/getcomp-js.t
#prove -e './nqp-js' t/nqp/{01..29}*.t t/nqp/{31..48}* t/nqp/{50,51,53}* t/nqp/{55..81}* t/nqp/83* t/serialization/0{2,3}*.t
16 changes: 11 additions & 5 deletions src/vm/js/nqp-runtime/runtime.js
Expand Up @@ -91,23 +91,29 @@ HashIter.prototype.shift = function() {
};

function IterPair(hash, key) {
this.key = key;
this.hash = hash;
this._key = key;
this._hash = hash;
}

IterPair.prototype.iterval = function() {
return this.hash[this.key];
return this._hash[this._key];
};
IterPair.prototype.iterkey_s = function() {
return this.key;
return this._key;
};

IterPair.prototype.key = function(ctx, named) {
return this._key;
};
IterPair.prototype.value = function(ctx, named) {
return this._hash[this._key];
};


op.iterator = function(obj) {
if (obj instanceof Array) {
return new Iter(obj);
} else if (obj instanceof Hash) {
console.log(obj);
return new HashIter(obj);
} else {
throw "unsupported thing to iterate over";
Expand Down

0 comments on commit ea1190b

Please sign in to comment.