From 08873c7d6ecaaf71a4bd7ced39b6ddb7d9c10e26 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 5 Aug 2011 13:01:05 -0500 Subject: use a non-broken test for scalar values (t0m, rafl) --- XS.xs | 8 +++----- t/07-edge-cases.t | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/XS.xs b/XS.xs index fc3078a..11428d5 100644 --- a/XS.xs +++ b/XS.xs @@ -217,11 +217,9 @@ static int _valid_for_type(SV *value, vartype_t type) switch (type) { case VAR_SCALAR: - /* XXX: something weird is going on here - apparently values can - * be SVt_NULL but also be SvROK (and also, SVt_NULL isn't SvOK) */ - if (sv_type == SVt_NULL) - return 1; - return SvROK(value) ? SvOK(SvRV(value)) : SvOK(value); + return sv_type != SVt_PVAV && sv_type != SVt_PVHV && + sv_type != SVt_PVCV && sv_type != SVt_PVFM && + sv_type != SVt_PVIO; case VAR_ARRAY: return sv_type == SVt_PVAV; case VAR_HASH: diff --git a/t/07-edge-cases.t b/t/07-edge-cases.t index acd92e8..6bed48e 100755 --- a/t/07-edge-cases.t +++ b/t/07-edge-cases.t @@ -63,6 +63,12 @@ is(exception { $Bar->add_symbol('$foo', \$foo) }, undef, "can add PVIV values"); is(exception { $Bar->add_symbol('$bar', \$bar) }, undef, "can add PVNV values"); +is(exception { bless \$bar, 'Foo'; $Bar->add_symbol('$bar2', $bar) }, undef, + "can add PVMG values"); +is(exception { $Bar->add_symbol('$baz', qr/foo/) }, undef, + "can add regex values"); +is(exception { undef $bar; $Bar->add_symbol('$quux', \$bar) }, undef, + "can add undef values that aren't NULL"); use_ok('CompileTime'); -- cgit v1.2.3-54-g00ecf