summaryrefslogtreecommitdiff
path: root/lib/overload.t
Commit message (Collapse)AuthorAgeFilesLines
* [perl #71998] overload::Method can die with blessed methodsFather Chrysostomos2010-09-281-1/+9
| | | | | | | | | | | | | | | | | | If an overload method is itself blessed into a class that has overloaded operators but does not have fallback enabled, then an error is produced: $ perl5.10.0 use overload '+' => sub{}; bless overload::Method main => '+'; overload::Method main => '+'; ^D Operation "ne": no method found, left argument in overloaded package main, right argument has no overloaded magic at /usr/local/lib/perl5/5.10.0/ overload.pm line 59. The attached patch fixes this.
* Test %main::OVERLOAD, which was almost broken by a proposed fix forFather Chrysostomos2010-09-131-1/+10
| | | | [perl #76138].
* Fix the overload tests marked as TODO in ↵Chris 'BinGOs' Williams2010-08-151-6/+4
| | | | | | 22afb09b13a6dc17f20388991422fdbe6166e3ed As is() doesn't stringify its arguments anymore we have to.
* Made a number of tests TODO in lib/overload.t due to changes to Test-SimpleChris 'BinGOs' Williams2010-08-141-1/+3
| | | | | | | | | Feature Changes * is() and others will no longer stringify its arguments before comparing. Overloaded objects will make use of their eq overload rather than their "" overload. This can break tests of impolitely string overloaded objects. DateTime prior to 0.54 is the biggest example.
* avoid multiple FETCH/stringify on filetest opsDavid Mitchell2010-07-031-11/+1
| | | | | some of the filetest operators could call mg_get and/or overload fallback stringify multiple times
* avoid extra FETCHes on overloaded qr stringifyDavid Mitchell2010-07-031-4/+1
| | | | | /$tied/ called FETCH too many times if the FETCH returned an overloaded object with no qr method, but with stringify fallback
* overload.t: clarify concat #FETCH expectedDavid Mitchell2010-07-031-16/+10
| | | | | It turns out that the number of FETCHes for the fallback ($tied_ovld . foo) just needed explaining, not fixing.
* remove double stringify-overload from $ovld .= fooDavid Mitchell2010-07-031-11/+3
| | | | | | | There was a piece of code in pp_concat who's job it was to determine the UT8ness of the LHS, and it did it in a heavy-handed way to cope with the special case of a regexp (which is an RV pointing to REGEXP which might be UTF8)
* eval: handle taint of overloaded/tied argDavid Mitchell2010-07-031-2/+6
| | | | | | string eval would check its arg for taint before processing magic, overload etc. If the magic or overload returned a tainted value, it wouldn't be detected. Fixes part of #75716.
* fix tainting and overloadDavid Mitchell2010-07-031-62/+246
| | | | | | | | | | | | | | | | | | | | | Sometimes when an overload method returned a tainted value, that taintedness got lost. This fixes #75716: overload removes tainting. It also considerably expands the tied series of tests in overload.t. It now taints the return value, and checks for correct taintedness. It also tests against two overload packages: the new one only has fallback methods, which affects the return path for the tainted value. It now also compares the expected (non-tied, non-overload) expression value against a overloaded version of that expression in addition to versions where a tied var returned an overloaded object; e.g. in these expressions: 1: 1 + $plain_value 2: 1 + $overloaded_var 3: 1 + $tied_scalar_that_returns_overloaded_value 4: 1 + $tied_array_whose element_0_holds_an_overloaded_value[0] then the value of expression 1 is compared against each of 2,3,4, whereas before it was only compared against 3,4.
* taint-enable lib/overload.tDavid Mitchell2010-07-031-4/+4
| | | | | | | | | Stick a -T at the top of lib/overload.t in preparation for adding some taint tests later. This causes some of the current tests to fail, since the FETCH count has changed: so we fix those up too. They change because under taint, code like ${$x} is compiled as enter/gvsv/leave/rv2sv rather than gvsv/rv2sv (see Perl_scope), and the leave creates a mortal copy of the tied value, avoiding any further fetches.
* fix for RT #8438: $tied->() doesn't call FETCHDavid Mitchell2010-06-041-1/+1
| | | | | | pp_entersub checked for ROK *before* calling magic. If the tied scalar already had ROK set (perhaps from a previous time), then get magic (and hence FETCH) wasn't called.
* make overload respect get magicDavid Mitchell2010-05-211-1/+240
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In most places, ops checked their args for overload *before* doing mg_get(). This meant that, among other issues, tied vars that returned overloaded objects wouldn't trigger calling the overloaded method. (Actually, for tied and arrays and hashes, it still often would since mg_get gets called beforehand in rvalue context). This patch does the following: Makes sure get magic is called first. Moves most of the overload code formerly included by macros at the start of each pp function into the separate helper functions Perl_try_amagic_bin, Perl_try_amagic_un, S_try_amagic_ftest, with 3 new wrapper macros: tryAMAGICbin_MG, tryAMAGICun_MG, tryAMAGICftest_MG. This made the code 3800 bytes smaller. Makes sure that FETCH is not called multiple times. Much of this bit was helped by some earlier work from Father Chrysostomos. Added new functions and macros sv_inc_nomg(), sv_dec_nomg(), dPOPnv_nomg, dPOPXiirl_ul_nomg, dPOPTOPnnrl_nomg, dPOPTOPiirl_ul_nomg dPOPTOPiirl_nomg, SvIV_please_nomg, SvNV_nomg (again, some of these were based on Father Chrysostomos's work). Fixed the list version of the repeat operator (x): it now only calls overloaded methods for the scalar version: (1,2,$overloaded) x 10 no longer erroneously calls x_method($overloaded,10)) The only thing I haven't checked/fixed yet is overloading the iterator operator, <>.
* Fix stringification assumption bug in overload.t, revealed by ia64-linux-ld.Nicholas Clark2010-03-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | Specifically: 1: / returns and NV where possible, only returning an integer if the dividend is an integer larger than an NV can represent accurately, and integer division is exact (ie no fractional part/remainder). 2: The test is performing $ref/1, intending it to be an identity operation on the numeric value of the reference. 3: The test assumes that the return result of the division will be a number that stringifies identically to the integer value of the reference. The fails if both: 1: The system memory map is such that addresses are very large (ia64 does) 2: NVs are large enough to hold these addresses because then the address becomes converted to an NV which has sufficient decimal digits that stringification defaults to scientific notation. Itanium Linux users the world over will be cheering because they can now compile Perl with long doubles with confidence that all tests pass.
* fix bug 67156: overload: nomethod(..., '!') return value invertedMichael Breen2009-12-141-2/+17
|
* Improvements to qr-overload testsRafael Garcia-Suarez2009-11-011-8/+15
| | | | | | - Fix test for error message - Add negative test cases - Remove unneeded evals
* Implement the 'qr' overload type.Ben Morrow2009-11-011-1/+79
| | | | | | | | | | | If this is defined, it will be called instead of stringification whenever an object is used as a regexp or interpolated into a regexp. This will fall back to stringification even without C<fallback => 1>, for compatibility. An overloaded 'qr' must return either a REGEXP or a ref to a REGEXP (such as created by qr//). Any further overloading on the return value will be ignored.
* Test that overload::constant works in eval("")Rafael Garcia-Suarez2009-01-121-1/+8
|
* Re: unless(...) terser than if(!...)Vincent Pit2008-09-071-1/+41
| | | | | Message-ID: <48B86060.4090905@profvince.com> p4raw-id: //depot/perl@34310
* [perl #55786] [PATCH blead] Re: Overload Segfaulting Rick Delaney2008-06-151-1/+17
| | | | | | From: Rick Delaney (via RT) <perlbug-followup@perl.org> Message-ID: <rt-3.6.HEAD-22068-1213469460-652.55786-75-0@perl.org> p4raw-id: //depot/perl@34055
* Make new regex type be 'REGEXP' and make all core qr//'s be in class Regexp ↵Yves Orton2008-01-061-1/+1
| | | | | (and related changes) p4raw-id: //depot/perl@32880
* First class regexps.Nicholas Clark2007-12-281-1/+1
| | | p4raw-id: //depot/perl@32751
* Regexps are now orange.Nicholas Clark2007-12-271-1/+1
| | | | | (Correct a comparison of $] with 5.011 in B.pm) p4raw-id: //depot/perl@32740
* Fix overloading for 64-bit ints (revised)Jerry D. Hedden2007-10-191-2/+25
| | | | | | From: "Jerry D. Hedden" <jdhedden@cpan.org> Message-ID: <1ff86f510710181149s1c096dd9qffa8fe42046e675b@mail.gmail.com> p4raw-id: //depot/perl@32141
* Suggestion by Rick Delaney to make this test pass with -Duse64bitallRafael Garcia-Suarez2007-10-081-1/+1
| | | | | on HP-UX (see bug #46011) p4raw-id: //depot/perl@32071
* Re: [perl #46011] [RESOLVED] overload "0+" doesn't handle integer resultsRick Delaney2007-10-081-1/+6
| | | | | Message-ID: <20071008023701.GI29047@bort.ca> p4raw-id: //depot/perl@32062
* Re: [perl #46011] overload "0+" doesn't handle integer resultsRick Delaney2007-10-071-1/+26
| | | | | Message-ID: <20071007042214.GH29047@bort.ca> p4raw-id: //depot/perl@32059
* I can't spell (well know fact) and while I'm there correct otherNicholas Clark2007-10-031-8/+8
| | | | | spelling, grammar and capitalisation imperfections. p4raw-id: //depot/perl@32017
* Test for a subtle pre-5.10 bug. Before 5.10 the overloading flag wasNicholas Clark2007-10-031-1/+43
| | | | | | | | | | | | stored on the reference rather than the referent. Despite the fact that objects can only be accessed via references (even internally), the referent actually knows that it's blessed, not the references. So taking a new, unrelated, reference to it gives an object. However, the overloading-or-not flag was on the reference prior to 5.10, and taking a new reference didn't (use to) copy it (prior to 5.8.9). So test that the bug can't return - overloading should work on a reference to something already blessed into a package with overloading. p4raw-id: //depot/perl@32016
* Re: [perl #41546] perl 5.8.x bug: overloaded 'eq' does not work with 'nomethod'Rick Delaney2007-02-231-1/+48
| | | | | Message-ID: <20070221215316.GF5646@bort.ca> p4raw-id: //depot/perl@30383
* [perl #36689] &=, |= and ^= overloads are nbot documentedAdriano Ferreira2006-11-241-1/+34
| | | | | | From: "Adriano Rodrigues" <a.r.ferreira@gmail.com> Message-ID: <73ddeb6c0611231143y1e3461dbqf30f5fce16698b5c@mail.gmail.com> p4raw-id: //depot/perl@29373
* D'oh! 27508 wasn't quite testing what I wanted it to test. This does.Nicholas Clark2006-03-151-3/+2
| | | p4raw-id: //depot/perl@27510
* Test for reblessing objects with weak references.Nicholas Clark2006-03-151-1/+30
| | | p4raw-id: //depot/perl@27508
* Moving the overloading flag from the reference to the referant allowsNicholas Clark2006-03-151-1/+46
| | | | | (re)?blessing of overloaded objects to work correctly. p4raw-id: //depot/perl@27506
* Finish converting overload.t to Test::MoreNicholas Clark2006-03-151-132/+100
| | | p4raw-id: //depot/perl@27505
* Further conversion of overload.tNicholas Clark2006-03-151-81/+81
| | | p4raw-id: //depot/perl@27504
* Further conversion of overload.tNicholas Clark2006-03-151-57/+58
| | | p4raw-id: //depot/perl@27502
* Partially convert overload.t to Test::MoreNicholas Clark2006-03-151-31/+31
| | | p4raw-id: //depot/perl@27501
* Test that constant overloading is propagated into evalRobin Houston2005-12-291-1/+8
| | | | | Message-ID: <20051226175648.GA28402@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@26521
* Re: [PATCH perl-current] Re: [perl #31793] Data::Dumper: Useqq interacts ↵Rick Delaney2004-11-041-1/+5
| | | | | | | badly with overloading Message-ID: <20041104004616.GA11214@biff.bort.ca> p4raw-id: //depot/perl@23470
* Mostly revert change #23347 (keep the test suite, fixed),Rafael Garcia-Suarez2004-11-031-1/+1
| | | | | | having decided that it wasn't a correct fix for bug #31793. p4raw-link: @23347 on //depot/perl: d411a6a9eb5df09116806ed1c441d30d37e8d5e8 p4raw-id: //depot/perl@23469
* Turn regcomp into a list opDave Mitchell2004-10-101-1/+25
| | | p4raw-id: //depot/perl@23357
* Re: [perl #31793] Data::Dumper: Useqq interacts badly with overloadingRick Delaney2004-10-041-3/+18
| | | | | Message-ID: <20041002050448.GB5059@biff.bort.ca> p4raw-id: //depot/perl@23347
* Numeric comparison operators mustn't compare addresses of referencesNicholas Clark2004-07-141-2/+38
| | | | | that are overloaded. p4raw-id: //depot/perl@23106
* Correct detection of absent modules. Based onAndy Dougherty2004-06-251-1/+1
| | | | | | | | Subject: [PATCH] Config{extensions} uses filesystem names as extensions Message-ID: <Pine.SOL.4.58.0406241505530.14039@maxwell.phys.lafayette.edu> with improvements from Marcus Holland-Moritz p4raw-id: //depot/perl@22998
* Skip tests if List::Util not builtNicholas Clark2004-06-221-0/+5
| | | p4raw-id: //depot/perl@22967
* [PATCH lib/overload.t] TODO tests for bug #24313.Rafael Garcia-Suarez2003-10-281-8/+23
| | | | | | | | | | | | From: Abigail <abigail@abigail.nl> Date: Mon, 27 Oct 2003 13:05:37 +0100 Message-ID: <20031027120536.GA24608@abigail.nl> Subject: [PATCH bleadperl] [perl #24313] (was Re: [PATCH lib/overload.t] TODO tests for bug #24313.) From: Rick Delaney <rick@bort.ca> Date: Mon, 27 Oct 2003 12:17:49 -0500 Message-ID: <20031027121749.E2233@biff.bort.ca> p4raw-id: //depot/perl@21566
* Re: [perl #19582] [PATCH bleedperl] bad overload copy constructor segfaultsRick Delaney2003-09-181-1/+17
| | | | | | | | | Message-ID: <20030101225459.A2320@cs839290-a.mtth.phub.net.cable.rogers.com> (Pity the first patch fell through the cracks back then. Not that forbidding non-object copy constructors is the right thing to do but the bug could use fixing.) p4raw-id: //depot/perl@21276
* [perl #22753] overload::StrVal() fails for regexp refsFergal Daly2003-06-221-1/+3
| | | | | | From: "fergal@esatclear.ie (via RT)" <perlbug-followup@perl.org> Message-ID: <rt-22753-59662.14.6066295633041@rt.perl.org> p4raw-id: //depot/perl@19840
* sv_2pv_flags and ROK and UTF8 flagsYitzchak Scott-Thoennes2002-09-081-7/+8
| | | | | | | | Date: Wed, 04 Sep 2002 21:09:01 -0700 Message-ID: <djtd9gzkgyLd092yn@efn.org> Date: Fri, 06 Sep 2002 09:23:03 -0700 Message-ID: <nZNe9gzkgKdH092yn@efn.org> p4raw-id: //depot/perl@17864