summaryrefslogtreecommitdiff
path: root/t/op/stash.t
Commit message (Collapse)AuthorAgeFilesLines
* Non-invasive mojibake fixesStanislaw Pusep2015-07-031-2/+2
| | | | | | Fixing minor encoding inconsistencies found by scan_mojibake utility (https://metacpan.org/pod/distribution/Test-Mojibake/bin/scan_mojibake) This patch is touching only comments/POD/__DATA__
* [perl #123847] crash with *foo::=*bar::=*with_hashFather Chrysostomos2015-03-111-1/+8
| | | | | | When a hash has no canonical name and one effective name, the array of names has a null pointer at the beginning. hv_ename_add was not tak- ing that into account, and was trying to dereference the null pointer.
* Avoid vivifying stuff when looking up barewordsFather Chrysostomos2014-08-291-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Till now, when a bareword was looked up to see whether it was a sub- routine, an rv2cv op was created (to allow PL_check hooks to override the process), which was then asked for its GV. Afterwards, the GV was downgraded back to nothing if possible. So a lot of the time a GV was autovivified and then discarded. This has been the case since f74617600 (5.12). If we know there is a good chance that the rv2cv op is about to be deleted, we can avoid that by passing a flag to the new op. Also f74617600 actually changed the behaviour by vivifying stashes that used not be vivified: sub foo { print shift, "\n" } SUPER::foo bar if 0; foo SUPER; Output in 5.10: SUPER Output as of this commit: SUPER Output in 5.12 to 5.21.3: Can't locate object method "foo" via package "SUPER" at - line 3.
* Fatalize defined(@) and defined{%)Karl Williamson2014-06-161-20/+1
| | | | | | | | | Calling defined on an array or hash has been deprecated and scheduled for removal in v5.22. This commit does that, removing the tests that assumed they were defined. In order to get the line numbers of the errors to display, I combined the first and second lines of the message, omitting the \n
* [perl #121031] fix all of the other incorrect calls to fresh_perl_is()Tony Cook2014-01-201-2/+2
| | | | | The third argument to fresh_perl_is()/fresh_perl_like() is treated as a hashref, passing a string is kind of strange.
* Refactor 3 tests so that they avoid clearing %:: via list assignment.Nicholas Clark2013-05-211-4/+5
| | | | | | | | For all 3, clearing %:: was intended to expose another bug, not to directly test the effects of clearing %:: Tested by building the 3 revisions that added the tests, and confirming that the revised test also triggers the bug that each fixed.
* Set PL_stderrgv to NULL if it is freed.Nicholas Clark2013-03-061-1/+8
| | | | | Without this, it's possible to hit assertion failures when global destruction attempts to skip the PVIO for PL_stderrgv while cleaning up all objects.
* stash.t: 2 TODO tests I missedFather Chrysostomos2012-06-051-4/+1
|
* stash.t: Un-TODO passing testsFather Chrysostomos2012-06-041-4/+1
|
* Restore autouse’s exemption from redef warningsFather Chrysostomos2011-11-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also restores the subroutine redefinition warning for newly-cre- ated XSUBs outside the autouse package. See below. This commit added the exemption to fix a known bug, that loading a module and importing from it would cause a redefinition warning if there were an autouse stub: perl-5.004_03-1092-g2f34f9d commit 2f34f9d4825ac9262ece854fc4c50479f4838ff8 Author: Ilya Zakharevich <ilya@math.berkeley.edu> Date: Mon Mar 2 16:36:02 1998 -0500 Make autouse -w-safe p4raw-id: //depot/perl@781 The subroutine redefinition warning occurs in three places. This commit removed the autouse exemption from two of them. I can’t see how it wasn’t a mistake, as <5104D4DBC598D211B5FE0000F8FE7EB202D49EE9@mbtlipnt02.btlabs.bt.co.uk> (the apparent source of the patch, makes no mention of it: perl-5.005_02-2920-ge476b1b commit e476b1b5c29f354cf8dad61a9fc6d855bdfb5b7d Author: Gurusamy Sarathy <gsar@cpan.org> Date: Sun Feb 20 22:58:09 2000 +0000 lexical warnings update, ability to inspect bitmask in calling scope, among other things (from Paul Marquess) p4raw-id: //depot/perl@5170 This commit refactored things to remove some compiler warnings, but in doing so reversed the logic of the condition, causing redefini- tion warnings for newly-created XSUBs to apply only to subs from the autouse package: perl-5.8.0-5131-g66a1b24 commit 66a1b24beb76ea873ad4caa57ee3ab9df945afbf Author: Andy Lester <andy@petdance.com> Date: Mon Jun 6 05:11:07 2005 -0500 Random cleanups #47 Message-ID: <20050606151107.GC7022@petdance.com> p4raw-id: //depot/perl@24735 I’ve basically reinstated the changes in 2f34f9d4, but with tests this time. It may not make sense for autouse to be exempt for newATTRSUB and newXS, but keeping the logic surrounding the warning as close as possible to being the same could allow future refactorings to merge them.
* Add class_ok() and object_ok() to t/test.pl.Michael G. Schwern2011-11-171-3/+3
| | | | | | | | | | Change every existing instance of isa_ok() to use object_ok(). This is safe because before this point, t/test.pl's isa_ok() only worked on objects. lib/dbmt_common.pl is the last hold out because it uses Test::More. These are like isa_ok() but they also check if it's a class or an object. This lets the core tests defend against outlandish bugs while allowing t/test.pl to retain feature parity with Test::More.
* [perl #101486] Make PL_curstash refcountedFather Chrysostomos2011-10-221-1/+9
| | | | | | | | | | This stops PL_curstash from pointing to a freed-and-reused scalar in cases like ‘package Foo; BEGIN {*Foo:: = *Bar::}’. In such cases, another BEGIN block, or any subroutine definition, would cause a crash. Now it just happily proceeds. newATTRSUB and newXS have been modified not to call mro_method_changed_in in such cases, as it doesn’t make sense.
* Dont’t crash when warning about XSUB redefinitionFather Chrysostomos2011-10-081-1/+12
| | | | | | | | If the stash in question has no name, the attempt to generate the warning will cause a crash. Simply skipping the warning is this case is fine, as this is will into ‘undefined’ territory (but it still shouldn’t crash).
* [perl #88138] ' is not equivalent to :: before a nullFather Chrysostomos2011-06-031-1/+5
| | | | | | | | | ' is usually equivalent to :: in a symbol name. At the *end* of a symbol name (as in $'), it’s not equivalent. (That’s a feature.) Perl_gv_fetchpvn_flags was checking for the end by saying if(next character), which returns false for a null. It should be checking the length, which it was already doing for ::, and which this commit makes it do.
* [perl #88132] broken ISA lookup after aliasing packages ending with ::Father Chrysostomos2011-04-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | gv_fetchpvn_flags did not always assign a name to a return HV ending with ::. This would result in code in various places skipping certain ‘stashes’ (in quotes because nameless HVs are technically not stashes) because they were nameless when they should not have been. So sometimes ISA caches would end up being out of date, as in the test cases posted with [perl #88132] (and incorporated into this patch). This commit fixes that by changing the parsing of glob names. Formerly, a :: was not considered a package separator if it came imme- diately after a ::. So foo:::: would become foo::/:: (with the final :: considered a regular stash entry, not a ‘stash’ stash entry) and foo:::::: would become foo::/:::/:. Now a :: is always a package separator. So *foo::::bar is accessible via $foo::{"::"}{bar} and *$foo:::::: via $foo::{"::"}{"::"}. This happens to fix [perl #88134] as well.
* Correct the skip count in stash.tFather Chrysostomos2011-04-081-1/+1
| | | | This has been wrong since 57f45d7.
* [perl #87664] Don’t autovivify stashes when anonymising CVsFather Chrysostomos2011-04-031-1/+14
| | | | | | | | | | | | | | | | | | | | | | | This commit stops CV anonymisation from autovivifying stashes to point to (unless the stash is %__ANON__::). If a stash has been deleted from its original position in the symbol table, then its HvNAME will no longer indicate where to find it. S_anonymise_cv_maybe in sv.c was using the HvNAME to look up (and autovivify) the *__ANON__ glob in the stash, without taking into account that it might not actually be looking in the right spot. So now, after checking that the stash still has a name (HvNAME), it uses the HvENAME to find it. If the HvENAME is null, which indicates that the stash has been detached altogether, then %__ANON__:: is used, as happens when HvNAME is null. This solves a Class::Monadic failure introduced by commit 2d0d1eccfc ([perl #79208] %stash:: = () anonymises CVs), which was included in 5.13.7. Basically, it can be reduced to this:
* stash.t: make TODO tests only TODO under threadsDavid Mitchell2011-01-041-2/+5
| | | | .. since they only fail under threads.
* Test that the stash and file of a sub's definition overrides those of its stub.Nicholas Clark2010-11-181-2/+31
| | | | | This is the current behaviour for Perl_newATTRSUB(), and it turns out that we have no test for it.
* stash.t: The [perl #58530] test should not be skippedFather Chrysostomos2010-11-151-10/+10
|
* Correct an anonymisation test in stash.tFather Chrysostomos2010-11-151-3/+1
|
* Correct skip count in stash.tFather Chrysostomos2010-11-151-1/+1
|
* [perl #79208] %stash:: = () anonymises CVsFather Chrysostomos2010-11-151-2/+12
| | | | | | | | | | | | | This keeps stash names visible during %foo:: = (). This fixes @ISA assignment inside a DESTROY method triggered by %foo:: = () and also lets existing CVs retain their pointers to the stash. So %foo:: = () is now equivalent to delete $foo::{$_} for keys %foo::
* Mark failing tests in t/op/stash.t as to-doFather Chrysostomos2010-10-271-4/+10
| | | | | | Commit 78b79c775, in adding test for the breakage introduced in 35759254, inadvertently triggered a bug that goes back at least to perl 5.8.7, but which only occurs with threads.
* Renaming of stashes should not be visible from PerlFather Chrysostomos2010-10-271-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | Change 35759254 made stashes get renamed when moved around. This had an unintended consequence: Typeglobs, ref() return values, stringifi- cation of blessed references and __PACKAGE__ are all affected by this. This commit makes a new distinction between stashes’ names and effect- ive names. Stash names are now unaffected when the stashes move around. Only the effective names are affected. (The apparent presence of any puns in the previous sentence is purely incidental and most likely the result of the reader’s inferential propensity.) To this end a new HvENAME_get macro is introduced, returning the first effective name (what HvNAME_get was returning). (Only one effective name needs to be in effect at a time.) hv_add_name and hv_delete_name have been renamed hv_add_ename and hv_delete_ename. hv_name_set is modified to leave the effective names in place unless the name is being set to NULL. These names are now stored in HvAUX as follows: When xhv_name_count is 0, xhv_name is a HEK pointer, containing the name which is also the effective name. When xhv_name_count is not zero, then xhv_name is a pointer to an array of HEK pointers. If xhv_name_count is positive, the first HEK is the name *and* one of the effective names. When xhv_name_count is negative, the first HEK is the name and subsequent HEKs are the effective names.
* add CVf_CVGV_RC flagDavid Mitchell2010-07-181-1/+10
| | | | | | | | | | | | | after the recent commit 803f274831f937654d48f8cf0468521cbf8f5dff, the CvGV field is sometimes reference counted. Since it was intended that the reference counting would happen only for anonymous CVs, the CVf_ANON flag was co-opted to indicate whether RC was being used. This is not entirely robust; for example, sub __ANON__ {} is a non-anon sub which points to the same GV used by anon subs, which while itself doesn't directly break things, shows that the potential for breakage is there. So add a separate flag just to indicate the reference count status of the CvGV field.
* protect CvGV weakref with backrefDavid Mitchell2010-07-141-52/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each CV usually has a pointer, CvGV(cv), back to the GV that corresponds to the CV's name (or to *foo::__ANON__ for anon CVs). This pointer wasn't reference counted, to avoid loops. This could leave it dangling if the GV is deleted. We fix this by: For named subs, adding backref magic to the GV, so that when the GV is freed, it can trigger processing the CV's CvGV field. This processing consists of: if it looks like the freeing of the GV is about to trigger freeing of the CV too, set it to NULL; otherwise make it point to *foo::__ANON__ (and set CvAONON(cv)). For anon subs, make CvGV a strong reference, i.e. increment the refcnt of *foo::__ANON__. This doesn't cause a loop, since in this case the __ANON__ glob doesn't point to the CV. This also avoids dangling pointers if someone does an explicit 'delete $foo::{__ANON__}'. Note that there was already some partial protection for CvGV with commit f1c32fec87699aee2eeb638f44135f21217d2127. This worked by anonymising any corresponding CV when freeing a stash or stash entry. This had two drawbacks. First it didn't fix CVs that were anonmous or that weren't currently pointed to by the GV (e.g. after local *foo), and second, it caused *all* CVs to get anonymised during cleanup, even the ones that would have been deleted shortly afterwards anyway. This commit effectively removes that former commit, while reusing a bit of the actual anonymising code.
* protect CvSTASH weakref with backrefsDavid Mitchell2010-07-141-1/+14
| | | | | | | | | | | | | | Each CV usually has a pointer, CvSTASH, back to the stash that it was complied in. This pointer isn't reference counted, to avoid loops. Which can leave it dangling if the stash is deleted. There is already protection for the similar GvSTASH field in GVs: the stash has an array of backrefs, xhv_backreferences, pointing to the GVs whose GvSTASHes point to it, and which is used to zero all the GvSTASH fields should the stash be deleted. All this patch does is also add the CVs with CvSTASH to that stash's backref list too.
* Remove the tokeniser hack that prevents compile-time vivification of %stash::Nicholas Clark2010-05-211-5/+5
| | | | | | | | | | | | | | | | This was put in to ensure that defined %stash:: continued to return false after the implementation of hashes was changed, such that stashes were always defined. defined %stash:: is deprecated. This reverts the tokeniser changes of adc51b978ed1b2e9d4512c9bfa80386ac917d05a, 76138434928a968a390c791aec92e5f00017d01d, d6069db2e52f58ef65bf59f2fd453604270d2205 and part of 9bde8eb087a2c05d4c8b0394a59d28a09fe5f529, and updates the tests added with those commits to reflect the restored (but as yet unreleased) behaviour. I don't think that this should be merged to blead until after 5.12.0 ships, with the enabled deprecation warnings on defined %hash, as it changes subtle behaviour that all current released stable perls accept without warning.
* Improvements to 31c9a3 - CPAN code did depend on the previous behaviour of ↵Nicholas Clark2010-02-061-2/+2
| | | | | | | | | | | | | | | | | | | blessing filehandles into FileHandle It turns out that it's not quite as simple as blessing into IO::File. If you do (just) that, then it breaks any existing code that does C<require IO::Handle;> to allow it to call methods on file handles, because they're blessed into IO::File, which isn't loaded. (Note this code doesn't assume that methods in IO::Seekable are there to be called) So, it all should work if you also set @IO::File:::ISA correctly? That way, code that assumes that methods from IO::Handle can be called will work. However, gv.c now starts complaining (but not failing) if IO::Handle, IO::Seekable and Exporter aren't present, because it goes looking for methods in them. So the solution seems to be to set @IO::File::ISA *and* create (empty) stashes for the other 3 packages. Patch appended, but not applied.
* Make defined %hash on a non-lexical (also) generate a deprecated warning.Nicholas Clark2009-10-241-8/+12
| | | | | Tk has been fixed, and no longer uses defined %stash:: to determine if a package has been loaded.
* Wrong skip count in t/op/stash.tMichael G Schwern2009-07-121-1/+1
| | | | | stash.t has the wrong number of tests to skip when dynamic loading is not available breaking minitest.
* Quiet t/op/stash.t outputJerry D. Hedden2009-06-301-3/+4
| | | | | | Attached patch to t/op/stash.t applies Craig Berry's fix (commit fbad106ea7f26c14f996d4ff2eb920ccffc44821) only on VMS. This keeps the noise from the affected tests from polluting the 'make test' output.
* Make stash.t redirect stderr.Craig A. Berry2009-06-271-0/+1
| | | | | Otherwise, on VMS, the subprocess exit status gets displayed and causes the test to fail.
* Fix blead segfault on Cygwin for t/op/stash.tBen Morrow2009-06-231-20/+44
|
* Tests for deleting stash entries.Ben Morrow2009-06-211-4/+82
|
* Re: Off by one in the trie code?Yves Orton2006-10-191-1/+1
| | | | | | | | Message-ID: <9b18b3110610181151i3ca438cdied769ebaa4255079@mail.gmail.com> change test files that do a require "./test.pl"; without a BEGIN block to ensure prototypes are seen, plus fix any breakage this reveals. p4raw-id: //depot/perl@29056
* defined %foo::bar:: wasn't working like it used to do in evalsRafael Garcia-Suarez2006-01-161-1/+6
| | | | | (and, consequently, when require'ing modules.) p4raw-id: //depot/perl@26867
* Since we no longer autovivify stashes (change #26370), we needRafael Garcia-Suarez2006-01-021-1/+7
| | | | | | | | to turn off strict-refs on them, or we'll have a stricture error the first time we'd try to access them (when they'll be actually autovivified). p4raw-link: @26370 on //depot/perl: adc51b978ed1b2e9d4512c9bfa80386ac917d05a p4raw-id: //depot/perl@26574
* Add a test for change 26547. (We no longer expect to see errors aboutNicholas Clark2005-12-311-1/+15
| | | | | unbalanced string table reference counts.) p4raw-id: //depot/perl@26548
* Don't autovivify stashes as soon as the lexer sees them.Rafael Garcia-Suarez2005-12-151-1/+13
| | | | | | This makes defined %foo::bar:: work again. Add tests for it, remove note in perldelta about having broken it. p4raw-id: //depot/perl@26370
* Fix a case of segfault in gv_check(), by makingRafael Garcia-Suarez2003-05-311-1/+9
| | | | | it ignore non-GV values in stashes. p4raw-id: //depot/perl@19652
* Re: [perl #15479] perl 5.8.0 segfaultRafael Garcia-Suarez2002-08-081-0/+18
Message-id: <20020802001310.7e1dc694.rgarciasuarez@free.fr> p4raw-id: //depot/perl@17695