Skip to content

Commit

Permalink
Make nqp::istype work on nqp::null().
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Feb 15, 2015
1 parent cc16234 commit 5272c6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -256,6 +256,11 @@ op.findmethod = function(obj, method) {
};

op.istype = function(obj, type) {
/* Null always type checks false. */
if (obj === null) {
return 0;
}

// TODO cases where the type_check_cache isn't authoritative
var cache = obj._STable.type_check_cache;
for (var i=0; i < cache.length; i++) {
Expand Down
4 changes: 3 additions & 1 deletion t/nqp/89-istype.t
@@ -1,6 +1,6 @@
#! nqp

plan(7);
plan(8);

class Foo {}

Expand All @@ -19,3 +19,5 @@ ok(!nqp::istype(Foo, Bar), 'istype with two types, -');
ok(nqp::istype($sub, Foo), 'istype with subclass, +');
ok(!nqp::istype($foo, FooSub), 'istype with subclass, -');
ok(nqp::istype(FooSub, Foo), 'istype with subclass type, +');

ok(!nqp::istype(nqp::null(), Foo), 'istype on nqp::null()')

0 comments on commit 5272c6b

Please sign in to comment.