summaryrefslogtreecommitdiff
path: root/ext/XS-APItest/t
Commit message (Collapse)AuthorAgeFilesLines
* Tests for goto &xsub and lexical hintsFather Chrysostomos2011-09-161-0/+17
| | | | | This new script tests that goto &xsub causes the sub to see the hints, not of the subroutine it replaces, but of that subroutine’s caller.
* Perl_rpeep: undo tail recursion optimisationDavid Mitchell2011-07-181-2/+4
| | | | | | | | | | | | | | | | commit 3c78429c102e0fe2ad30c60dfe52636b6071ef19 reduced the depth of recursion in rpeep(), by deferring recursion into branches until a bit later (so that the recursive call to rpeep was then likely to be shallow). However, it went one step further: when the chain of op_next's had been exhausted in the main loop, it processed any remaining deferrred branches in the main loop rather than recursing. All nice and efficient, but it broke the expectation that someone who had hooked into rpeep could follow the chain of op_nexts in each call and visit *all* ops. This commit removes that optimisation and restores the rpeep hook expectancy. This shouldn't have any major effect on the depth of recursion, and its minor inefficiency doesn't really matter for a one-time compilation-time pass.
* Actually test cop_*_labelReini Urban2011-07-171-0/+10
|
* make peep optimiser recurse mostly only shallowlyDavid Mitchell2011-07-141-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long blocks of code that include logical or loop ops (i.e. those with multiple 'branches' of ops, such as op_other, op_redo etc) cause Perl_rpeep to recurse deeply and eventaully SEGV. For example this crashes, due to the ENTERLOOP: eval ("{\$x = 1 }\n" x 10000) The deep recursion happens because the processing of the entire rest of the code occurs in within the nested call. For example in the code A && B; C; D; E; the ops are structured as A -> AND -> C -> D -> E \ / B where AND->op_next points to C, while AND->op_other points to B. rpeep() would normally process each op in the op_next sequence in turn (i.e. A/AND/C/D/E), but when it reaches AND, it recursively calls rpeep(B), which happens to then process B/C/D/E. Finally it returns, and the parent rpeep processes C, finds it's already done, and exits. Clearly, if C,D,E etc also contain conditional/loop ops, then the recursion level gradually stacks up. The fix for this is to add a small deferred queue to rpeep(). Whenever rpeep wants to recurse with op_other or op_lastop etc, it instead adds it to the deferred queue. Only if the queue is full is rpeep actually called. The hope is that by deferring, when we do eventually process it, enough of the main op_next chain has already been processed to ensure that the child rpeep returns very early. In the example above, processing of AND causes B to be added to the queue, and the main rpeep process continues processing C, D etc. Sometime later, the queue becomes full and B is processed via a recursive call to rpeep. B is processed, and op_next is followed to C, but C is marked as already processed, so the child rpeep returns almost immediately. For LOOP ops, I've stopped following op_redoop and op_nextop, since AFAIKT the ops these point to will also be reachable vie op_next anyway. op_lastop is the exception; in while(1){..} only op_lastop points to the rest of the code block. Note that this commit doesn't guarantee only shallow recursion, it just makes deep recursion fairly unlikely. Note also that this commit causes the order of the processing of op_next chains to be altered; this can affect the ordering of compiler warnings and fatal messages among potentially other things.
* Tests for the pad cleanup.Brian Fraser2011-07-121-2/+2
|
* pad.c: flags checking for the UTF8 flag when necessaryBrian Fraser2011-07-121-0/+321
|
* API tests for pad_findmy_*()Zefram2011-07-121-0/+75
|
* API test for find_rundefsv()Zefram2011-07-121-0/+20
|
* Make SvIsCOW honest about globsFather Chrysostomos2011-07-121-0/+13
| | | | | | | | SvIsCOW was ignoring the fact that it might be passed a typeglob, which made its behaviour contradict its docs. This fixes that and, in doing so, simplifies the upcoming Internals::SvREADONLY fix.
* Add a test for perl_clone with CLONEf_COPY_STACKS to XS-APItest.Gerard Goossen2011-07-041-0/+53
| | | | | CLONEf_COPY_STACKS is only used by the windows pseudo-fork. This test allows testing/debugging of CLONEf_COPY_STACK without needing threads or Windows.
* Completely free hashes containing nullsFather Chrysostomos2011-06-121-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a regression introduced since 5.14.0, by commit e0171a1a3. The new Perl_hfree_next_entry function that that commit introduced returns the value of the hash element, or NULL if there are none left. If the value of the hash element is NULL, the two cases are indistin- guishable. Before e0171a1a3, all the hash code took null values into account. mro_package_moved took advantage of that, stealing values out of a hash and leaving it to the freeing code to delete the elements. The two places that call Perl_hfree_next_entry (there was only one, S_hfreeentries, with commit e0171a1a3, but the following commit, 104d7b699c, made sv_clear call it, too) were not accounting for NULL values’ being returned, and could terminate early, resulting in mem- ory leaks. One could argue that the perl core should not be assigning nulls to HeVAL, but HeVAL is part of the public API and there could be CPAN code assigning NULL to it, too. So the safest approach seems to be to modify Perl_hfree_next_entry’s callers to check the number of keys and not to attribute a signifi- cance to a returned NULL.
* Tests for Perl_get_vtbl()Nicholas Clark2011-06-111-0/+2
|
* Warn when list-assigning to TEMPFather Chrysostomos2011-06-011-1/+5
|
* Tests for XS lvalue functionsFather Chrysostomos2011-06-011-0/+28
| | | | | including the ‘Useless assignment to a temporary’ warning which is only triggered by these.
* [perl #87064] eval no longer shares filtersFather Chrysostomos2011-04-031-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit: commit f07ec6dd59215a56bc1159449a9631be7a02a94d Author: Zefram <zefram@fysh.org> Date: Wed Oct 13 19:05:19 2010 +0100 remove filter inheritance option from lex_start The only uses of lex_start that had the new_filter parameter false, to make the new lexer context share source filters with the previous lexer context, were uses with rsfp null, which therefore never invoked source filters. Inheriting source filters from a logically unrelated file seems like a silly idea anyway. string evals could inherit the same source filter space as the cur- rently compiling code. Despite what the quoted commit message says, sharing source filters allows filters to be inherited in both direc- tions: A source filter created when the eval is being compiled also applies to the file with which it is sharing its space. There are at least 20 CPAN distributions relying on this behaviour (or, rather, what could be considered a Test::More bug). So this com- mit restores the source-filter-sharing capability. It does not change the current API or make public the API for sharing source filters, as this is supposed to be a temporary stop-gap measure for 5.14.
* Convert XS::APItest's svpv_magic.t to Test::More.Nicholas Clark2011-02-051-2/+3
|
* XS-APItest/t/caller.t: mark two passing testsDavid Mitchell2011-01-211-0/+1
| | | | | | | | | | | There are four TODO tests in caller.t, relating to the hints hash returned under the debugger. Since 20439bc77dfeec46d94a15cf108446039e26c995, two of these tests has started to pass. I don't understand this area enough to know whether that commit *should* have made them pass, but it seems fairly consistent. So un-TODO just those two. This means that under the debugger, we now expect to get a hints hash, but that its contents are still wrong.
* Fix typos (spelling errors) in ext/*.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81882] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81882 > Signed-off-by: Abigail <abigail@abigail.be>
* recursive-descent expression parsingZefram2010-12-111-0/+366
| | | | | | New API functions parse_fullexpr(), parse_listexpr(), parse_termexpr(), and parse_arithexpr(), to parse an expression at various precedence levels.
* Fix permissions for ext/XS-APItest/t/refs.t, added as +x in 88b5a879c6c933e0.Nicholas Clark2010-12-111-0/+0
|
* Fix test count in ext/XS-APItest/t/refs.tFather Chrysostomos2010-12-101-1/+1
|
* Fix XS types in typemap in order to deal with references with get magics ↵gfx2010-12-101-0/+34
| | | | correctly
* Add tests for sv_{,un}magicext and mg_findextFlorian Ragwitz2010-11-301-0/+30
|
* Tests for the new custom op registrations.Ben Morrow2010-11-141-0/+76
|
* Add Perl_bytes_cmp_utf8() to compare character sequences in different encodingsNicholas Clark2010-11-111-0/+27
| | | | | | | | | | | | | | | | | | | | | | | Convert sv_eq_flags() and sv_cmp_flags() to use it. Previously, to compare two strings of characters, where was was in UTF-8, and one was not, you had to either: 1: Upgrade the second to UTF-8 2: Compare the resulting octet sequence 3: Free the temporary UTF-8 string or: 1: Attempt to downgrade the first to bytes. If it can't be, they aren't equal 2: Else compare the resulting octet sequence 3: Free the temporary byte string Which for the general case involves a malloc()/free() and at least two O(n) scans per comparison. Whereas this approach has no allocation, a single O(n) scan, which terminates as early as the best case for the second approach.
* [perl #78964] Fix ext/XS-APItest/t/overload.tJerry D. Hedden2010-11-111-1/+1
| | | | | | | | | Attached patch fixes the following warning from 'make test': ext/XS-APItest/t/overload...................................."my" variable $got masks earlier declaration in same scope at t/overload.t line 81. ok
* Fix error in tryAMAGICunDEREF() introduced in 25a9ffce153b0e67.Nicholas Clark2010-11-091-22/+27
| | | | tryAMAGICunDEREF() isn't used anywhere in the core. Add tests for it.
* G_VOID, G_SCALAR, and G_ARRAY are not separate bits anymoreNiko Tyni2010-11-061-1/+10
| | | | | | | | Commit 2f8edad0d37e91319b6ba10b3745327ea49c179 made G_ARRAY equal to G_SCALAR | G_VOID, contrary to perlcall.pod. Bring the documentation up to date and add a test to prevent a similar (although unlikely) accident in the future.
* Add Perl_amagic_deref_call() to implement the bulk of tryAMAGICunDEREF_var().Nicholas Clark2010-11-031-4/+4
| | | | | | | | | This removes around 300 bytes of object code from each place it was previously inlined. It also provides a better interface - quite a lot of the core currently bodges things by creating a local variable C<SV **sp = &sv> to use the macro. Change the XS::APItest wrapper to amagic_deref_call().
* Add tests for tryAMAGICunDEREF_var().Nicholas Clark2010-11-031-0/+86
|
* new API functions op_scope and op_lvalueZefram2010-10-261-0/+60
| | | | | | The function scope() goes into the API as op_scope(), and mod() goes into the API as op_lvalue(). Both marked experimental, because their behaviour is a little quirky and not trivially dequirkable.
* function to parse isolated labelZefram2010-10-253-0/+288
| | | | | | | New API function parse_label() parses a label, separate from statements. If a label has not already been lexed and queued up, it does not use yylex(), but parses the label itself at the character level, to avoid unwanted lexing past an absent optional label.
* function to parse unlabelled statementZefram2010-10-252-2/+56
| | | | | New API function parse_barestmt() parses a pure statement, with no label, and returns just the statement's core ops, not attaching a state op.
* rt #72398 - get magic before downgrading in SvPVbyte()Tony Cook2010-10-251-3/+0
|
* TODO test: SvPVbyte should handle get magic before checking the utf8 flagNiko Tyni2010-10-251-0/+32
| | | | | | | | | | When $1 had the utf8 flag set from a previous match, SvPVbyte may croak with 'Wide character in subroutine entry' before resetting the flag to its new value. Add a support function and a TODO test for this in XS-APItest. http://bugs.debian.org/376329
* don't rely on ghost contexts being unmolestedZefram2010-10-241-0/+96
| | | | | | | | Dying and returning from a format both relied on the state of a just-popped context frame being preserved across a LEAVE. Don't rely on it. Test using an operator ripped off from Scope::Cleanup, which makes it easy to run arbitrary Perl code during cleanup, without isolating it on a separate context stack as the DESTROY mechanism does.
* Fix ext/XS-APItest/t/multicall.t warningJerry D. Hedden2010-10-211-0/+1
| | | | | | | | | | | 'make test' produces the following warning: ext/XS-APItest/t/multicall.....................................Useless use of private variable in void context at t/multicall.t line 37. ok The attached patch fixes this by adding a "no warnings 'void';" statement to the test file.
* full API for cop hint hashesZefram2010-10-211-0/+18
| | | | | | | | | | | | | Expose cop hint hashes as a type COPHH, with a cophh_* API which is a macro layer over the refcounted_he_* API. The documentation for cophh_* describes purely API-visible behaviour, whereas the refcounted_he_* documentation describes the functions mainly in terms of the implementation. Revise the cop_hints_* API, using the flags parameter consistently and reimplementing in terms of cophh_*. Use the cophh_* and cop_hints_* functions consistently where appropriate. [Modified by the committer to update two calls to Perl_refcounted_he_fetch recently added to newPMOP.]
* function to parse Perl code blockZefram2010-10-212-0/+224
| | | | | New API function parse_block() parses a code block, including surrounding braces. The block is a lexical scope, but not inherently a dynamic scope.
* fix and test PL_expect in recdescent parsingZefram2010-10-212-0/+113
| | | | | Set PL_expect at the start of parse_fullstmt() as well as at the start of parse_stmtseq(). Test both.
* handle bracket stack better in recdescent parsingZefram2010-10-213-2/+187
| | | | | | | | | | | | | When recursing into the parser for recursive-descent parsing, put a special entry on the bracket stack that generates a fake EOF if a closing bracket belonging to an outer parser frame is seen. This keeps the bracket stack balanced across a parse_stmtseq() frame, fixing [perl #78222]. If a recursive-descent parser frame ends by yyunlex()ing an opening bracket, pop its entry off the bracket stack and stash it in the forced-token queue, to be revived when the token is re-lexed. This keeps the bracket stack balanced across a parse_fullstmt() frame.
* avoid side-effecting source held in scalarZefram2010-10-211-0/+12
| | | | | | | | Syntax plugins can modify the source being parsed. It's fine for them to modify the lexer buffer, but this must not be the same scalar that was supplied to lex_start() and may be in use outside. Therefore always copy the scalar in lex_start() rather than just referencing it. Fixes [perl #78358].
* Recursive MULTICALL prematurely freed CVDavid Mitchell2010-10-191-1/+26
| | | | | | | | See [perl #78070]. Basically, POPSUB/LEAVESUB had a mechanism to decrement the reference count of the CV only at CvDEPTH==1; POP_MULTICALL was decrementing it at all depths.
* add skeleton testing for the MULTICALL macrosDavid Mitchell2010-10-191-0/+24
| | | | | | | | | | | | The macros dMULTICALL, PUSH_MULTICALL, MULTICALL and POP_MULTICALL are completely untested in core apart from incidentally in List-Util. The exercise they get there is probably quite comprehensive, but it's not explicitly testing the macros themselves. Add a hook and new test file to XS::APItest specifically for this purpose. Currently the test file is almost empty. The multicall_each function is shamelessly stolen from List:;Util::first.
* Add LINKLIST to the API.Ben Morrow2010-10-121-1/+4
| | | | | Also rename the underlying function to op_linklist, to match the other API op functions.
* APIify op list constructorsZefram2010-10-121-0/+10
| | | | | | Put into the API op_append_elem, op_prepend_elem, and op_append_list. All renamed from op_-less internal names. Parameter types for op_append_list changed to match the rest of the op API and avoid some casting.
* plugin mechanism to rewrite calls to a subroutineZefram2010-10-104-0/+191
| | | | | | | | | | | | | | | | | | | | | | | | New magic type PERL_MAGIC_checkcall attaches a function to a CV, which will be called as the second half of the op checker for an entersub op calling that CV. Default state, in the absence of this magic, is to process the CV's prototype if it has one, or apply list context to all the arguments if not. New API functions cv_get_call_checker() and cv_set_call_checker() provide a clean interface to this facility, hiding the internal use of magic. Expose in the API the new functions rv2cv_op_cv(), ck_entersub_args_list(), ck_entersub_args_proto(), and ck_entersub_args_proto_or_list(), which are meaningful segments of standard entersub op checking and are likely to be useful in plugged-in call checker functions. Expose new API function op_contextualize(), which is a public interface to the internal scalar()/list()/scalarvoid() functions. This API is likely to be required in most plugged-in call checker functions. Incidentally add new function mg_free_type(), in the API, which will remove magic of one type from an SV. (mg_free() removes all magic, and there isn't anything else more selective.)
* XS::APItest tests for XS_APIVERSION_BOOTCHECK.Nicholas Clark2010-10-081-0/+6
|
* xs_version_bootcheck() must use mortals, as {new,upg}_version() can croak.Nicholas Clark2010-10-081-0/+25
| | | | | | | It's unlikely that XS_VERSION will contain a bogus version string (for long), but the value passed in (or derived from $XS_VERSION or $VERSION) might well. For that case, without this change, temporary SVs created within xs_version_bootcheck() won't be freed (before interpreter exit).
* XS::APItest tests for XS_VERSION_BOOTCHECK.Nicholas Clark2010-10-071-0/+92
|