Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is to exceed 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - language - parse.y (source / functions) Hit Total Coverage
Test: PARI/GP v2.16.2 lcov report (development 29115-f22e516b23) Lines: 111 118 94.1 %
Date: 2024-05-18 08:06:58 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : %{
       2             : /* Copyright (C) 2006  The PARI group.
       3             : 
       4             : This file is part of the PARI package.
       5             : 
       6             : PARI/GP is free software; you can redistribute it and/or modify it under the
       7             : terms of the GNU General Public License as published by the Free Software
       8             : Foundation; either version 2 of the License, or (at your option) any later
       9             : version. It is distributed in the hope that it will be useful, but WITHOUT
      10             : ANY WARRANTY WHATSOEVER.
      11             : 
      12             : Check the License for details. You should have received a copy of it, along
      13             : with the package; see the file 'COPYING'. If not, write to the Free Software
      14             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      15             : 
      16             : #define PARI_STYPE union token_value
      17             : #define PARI_LTYPE struct node_loc
      18             : #define YYPTRDIFF_T long
      19             : #define YYPTRDIFF_MAXIMUM LONG_MAX
      20             : #define YYSIZE_T size_t
      21             : #define YYLLOC_DEFAULT(Current, Rhs, N)     \
      22             :         ((Current).start  = ((N)?(Rhs)[1].start:(Rhs)[0].end),  \
      23             :          (Current).end    = (Rhs)[N].end)
      24             : #include "parsec.h"
      25             : #define NOARG(x) newnode(Fnoarg,-1,-1,&(x))
      26             : #define NORANGE(x) newnode(Fnorange,-1,-1,&(x))
      27             : %}
      28             : %define parse.error verbose
      29             : %define api.prefix {pari_}
      30             : %define api.pure full
      31             : %parse-param {char **lex}
      32             : %lex-param {char **lex}
      33      927069 : %initial-action{ @$.start=@$.end=*lex; }
      34             : %token KPARROW ")->"
      35             : %token KARROW "->"
      36             : %token KDOTDOT ".."
      37             : %token KPE   "+="
      38             : %token KSE   "-="
      39             : %token KME   "*="
      40             : %token KDE   "/="
      41             : %token KDRE  "\\/="
      42             : %token KEUCE "\\="
      43             : %token KMODE "%="
      44             : %token KAND  "&&"
      45             : %token KOR   "||"
      46             : %token KID   "==="
      47             : %token KEQ   "=="
      48             : %token KNE   "!="
      49             : %token KGE   ">="
      50             : %token KLE   "<="
      51             : %token KSRE  ">>="
      52             : %token KSLE  "<<="
      53             : %token KSR   ">>"
      54             : %token KSL   "<<"
      55             : %token KDR   "\\/"
      56             : %token KPP   "++"
      57             : %token KSS   "--"
      58             : %token <gen> KINTEGER "integer"
      59             : %token <gen> KREAL "real number"
      60             : %token KENTRY "variable name"
      61             : %token KSTRING "character string"
      62             : %left SEQ DEFFUNC
      63             : %left INT LVAL
      64             : %right ")->" "->"
      65             : %left ';' ',' ".."
      66             : %right '=' "+=" "-=" "*=" "/=" "\\/=" "\\=" "%=" ">>=" "<<="
      67             : %left '&' "&&" "||"
      68             : %left "===" "==" "!=" '>' ">=" '<' "<="
      69             : %left '+' '-'
      70             : %left '%' "\\/" '\\' '/' '*' ">>" "<<"
      71             : %left SIGN
      72             : %right '^'
      73             : %left '#'
      74             : %left '!' '~' '[' DERIV
      75             : %left '\''
      76             : %left '.'
      77             : %left "++" "--"
      78             : %left '('
      79             : %left ':'
      80             : %type <val> seq sequence
      81             : %type <val> range matrix matrix_index expr exprno
      82             : %type <val> lvalue deriv
      83             : %type <val> matrixelts matrixeltsno matrixlines arg listarg definition
      84             : %type <val> funcid memberid
      85             : %type <val> backticks history
      86             : %type <val> compr in inseq
      87           0 : %destructor { pari_discarded++; } seq matrix range matrix_index expr exprno lvalue matrixelts matrixeltsno matrixlines arg listarg definition funcid memberid backticks history compr in inseq deriv
      88             : %%
      89             : 
      90      927069 : sequence: seq        {$$=$1; (void) pari_nerrs;} /* skip the destructor */
      91             : ;
      92             : 
      93       14888 : seq: /**/ %prec SEQ  {$$=NOARG(@$);}
      94     1287634 :    | expr %prec SEQ  {$$=$1;}
      95       40313 :    | seq ';'         {$$=$1; @$=@1;}
      96       30037 :    | seq ';' expr    {$$=newnode(Fseq,$1,$3,&@$);}
      97             : ;
      98             : 
      99         938 : range: /* */          { $$=newnode(Frange,NORANGE(@$),NORANGE(@$),&@$); }
     100       13400 :      | expr           { $$=newnode(Frange,$1,NORANGE(@$),&@$); }
     101         700 :      | expr ".." expr { $$=newnode(Frange,$1,$3,&@$); }
     102          98 :      | '^' expr       { $$=newnode(Frange,NORANGE(@$),$2,&@$); }
     103             : ;
     104             : 
     105        1666 : matrix_index: '[' range ',' range ']' {$$=newnode(Fmatrix,$2,$4,&@$);}
     106       11804 :             | '[' range ']'           {$$=newnode(Fmatrix,$2,-1,&@$);}
     107             : ;
     108             : 
     109          35 : backticks: '`' {$$=1;}
     110          84 :          | backticks '`' {$$=$1+1;}
     111             : ;
     112             : 
     113          49 : history: '%'           {$$=newopcall(OPhist,-1,-1,&@$);}
     114          14 :        | '%' KINTEGER  {$$=newopcall(OPhist,newintnode(&@2),-1,&@$);}
     115          28 :        | '%' backticks {$$=newopcall(OPhist,newnode(Fsmall,-$2,-1,&@$),-1,&@$);}
     116           7 :        | '%' '#'          {$$=newopcall(OPhisttime,-1,-1,&@$);}
     117          11 :        | '%' '#' KINTEGER {$$=newopcall(OPhisttime,newintnode(&@3),-1,&@$);}
     118           7 :        | '%' '#' backticks{$$=newopcall(OPhisttime,newnode(Fsmall,-$3,-1,&@$),-1,&@$);}
     119             : ;
     120             : 
     121         147 : deriv: '\'' {$$ = 1;}
     122          42 :      | deriv '\'' {$$ = $1+1;}
     123             : ;
     124             : 
     125    11721669 : expr: KINTEGER %prec INT  {$$=newintnode(&@1);}
     126        5142 :     | KREAL               {$$=newconst(CSTreal,&@$);}
     127           0 :     | '.'                 {$$=newconst(CSTreal,&@$);}
     128           0 :     | KINTEGER '.' KENTRY {$$=newnode(Ffunction,newconst(CSTmember,&@3),
     129             :                                                 newintnode(&@1),&@$);}
     130      843673 :     | KSTRING       {$$=newconst(CSTstr,&@$);}
     131        3377 :     | '\'' KENTRY   {$$=newconst(CSTquote,&@$);}
     132         116 :     | history           {$$=$1;}
     133         322 :     | expr '(' listarg ')'  {$$=newnode(Fcall,$1,$3,&@$);}
     134      192478 :     | funcid            {$$=$1;}
     135      275602 :     | lvalue %prec LVAL {$$=$1;}
     136     4343932 :     | matrix            {$$=$1;}
     137         739 :     | compr             {$$=$1;}
     138        8917 :     | definition        {$$=$1;}
     139        1145 :     | matrix '=' expr {$$=newnode(Fassign,$1,$3,&@$);}
     140       47001 :     | lvalue '=' expr {$$=newnode(Fassign,$1,$3,&@$);}
     141         183 :     | lvalue "++"     {$$=newopcall(OPpp,$1,-1,&@$);}
     142          28 :     | lvalue "--"     {$$=newopcall(OPss,$1,-1,&@$);}
     143         188 :     | lvalue "*="   expr {$$=newopcall(OPme,$1,$3,&@$);}
     144          35 :     | lvalue "/="   expr {$$=newopcall(OPde,$1,$3,&@$);}
     145           7 :     | lvalue "\\/=" expr {$$=newopcall(OPdre,$1,$3,&@$);}
     146           7 :     | lvalue "\\="  expr {$$=newopcall(OPeuce,$1,$3,&@$);}
     147           7 :     | lvalue "%="   expr {$$=newopcall(OPmode,$1,$3,&@$);}
     148           7 :     | lvalue "<<="  expr {$$=newopcall(OPsle,$1,$3,&@$);}
     149           7 :     | lvalue ">>="  expr {$$=newopcall(OPsre,$1,$3,&@$);}
     150         222 :     | lvalue "+="   expr {$$=newopcall(OPpe,$1,$3,&@$);}
     151          63 :     | lvalue "-="   expr {$$=newopcall(OPse,$1,$3,&@$);}
     152         735 :     | '!' expr         {$$=newopcall(OPnb,$2,-1,&@$);}
     153        3633 :     | '#' expr         {$$=newopcall(OPlength,$2,-1,&@$);}
     154         399 :     | expr "||"  expr  {$$=newopcall(OPor,$1,$3,&@$);}
     155         760 :     | expr "&&"  expr  {$$=newopcall(OPand,$1,$3,&@$);}
     156           0 :     | expr '&'   expr  {$$=newopcall(OPand,$1,$3,&@$);}
     157         343 :     | expr "===" expr  {$$=newopcall(OPid,$1,$3,&@$);}
     158       10333 :     | expr "=="  expr  {$$=newopcall(OPeq,$1,$3,&@$);}
     159        2100 :     | expr "!="  expr  {$$=newopcall(OPne,$1,$3,&@$);}
     160         111 :     | expr ">="  expr  {$$=newopcall(OPge,$1,$3,&@$);}
     161         473 :     | expr '>'   expr  {$$=newopcall(OPg,$1,$3,&@$);}
     162         237 :     | expr "<="  expr  {$$=newopcall(OPle,$1,$3,&@$);}
     163        1249 :     | expr '<'   expr  {$$=newopcall(OPl,$1,$3,&@$);}
     164       27800 :     | expr '-'   expr  {$$=newopcall(OPs,$1,$3,&@$);}
     165       54586 :     | expr '+'   expr  {$$=newopcall(OPp,$1,$3,&@$);}
     166         147 :     | expr "<<"  expr  {$$=newopcall(OPsl,$1,$3,&@$);}
     167          21 :     | expr ">>"  expr  {$$=newopcall(OPsr,$1,$3,&@$);}
     168         616 :     | expr '%'   expr  {$$=newopcall(OPmod,$1,$3,&@$);}
     169          28 :     | expr "\\/" expr  {$$=newopcall(OPdr,$1,$3,&@$);}
     170         161 :     | expr '\\'  expr  {$$=newopcall(OPeuc,$1,$3,&@$);}
     171      113595 :     | expr '/'   expr  {$$=newopcall(OPd,$1,$3,&@$);}
     172       56589 :     | expr '*'   expr  {$$=newopcall(OPm,$1,$3,&@$);}
     173          77 :     | '+' expr %prec SIGN {$$=$2;}
     174     4046595 :     | '-' expr %prec SIGN {$$=newopcall(OPn,$2,-1,&@$);}
     175       71353 :     | expr '^' expr {$$=newopcall(OPpow,$1,$3,&@$);}
     176        4382 :     | expr '~' {$$=newopcall(OPtrans,$1,-1,&@$);}
     177         147 :     | expr deriv %prec DERIV {$$=newopcall(OPderivn,$1, newnode(Fsmall,$2,-1,&@$),&@$);}
     178         236 :     | expr '!'  {$$=newopcall(OPfact,$1,-1,&@$);}
     179          28 :     | expr '#'  {$$=newopcall(OPprim,$1,-1,&@$);}
     180        4184 :     | expr matrix_index {$$=newnode(Fmatcoeff,$1,$2,&@$);}
     181       12383 :     | memberid {$$=$1;}
     182           0 :     | expr ':' KENTRY   {$$=newnode(Ftag,$1,0,&@$);}
     183       13494 :     | '(' expr ')' {$$=$2;}
     184             : ;
     185             : 
     186      327360 : lvalue: KENTRY %prec LVAL   {$$=newnode(Fentry,newconst(CSTentry,&@1),-1,&@$);}
     187        9286 :       | lvalue matrix_index {$$=newnode(Fmatcoeff,$1,$2,&@$);}
     188           0 :       | lvalue ':' KENTRY   {$$=newnode(Ftag,$1,newconst(CSTentry,&@2),&@$);}
     189             : ;
     190             : 
     191    11689845 : exprno: expr {$$=$1;}
     192          35 :       | /**/ {$$=NOARG(@$);}
     193             : 
     194    11689873 : matrixeltsno: matrixelts {$$=$1;}
     195           7 :             | /**/ {$$=NOARG(@$);}
     196             : ;
     197             : 
     198     4029238 : matrixelts: expr {$$=$1;}
     199    11689880 :           | matrixeltsno ',' exprno {$$=newnode(Fmatrixelts,$1,$3,&@$);}
     200             : ;
     201             : 
     202        8449 : matrixlines: matrixelts  ';' matrixelts {$$=newnode(Fmatrixlines,$1,$3,&@$);}
     203       20748 :            | matrixlines ';' matrixelts {$$=newnode(Fmatrixlines,$1,$3,&@$);}
     204             : ;
     205             : 
     206      343343 : matrix: '[' ']'             {$$=newnode(Fvec,-1,-1,&@$);}
     207         727 :       | '[' expr ".." expr ']' {$$=newopcall(OPrange,$2,$4,&@$);}
     208         959 :       | '[' ';' ']'         {$$=newnode(Fmat,-1,-1,&@$);}
     209     3991599 :       | '[' matrixelts ']'  {$$=newnode(Fvec,$2,-1,&@$);}
     210        8449 :       | '[' matrixlines ']' {$$=newnode(Fmat,$2,-1,&@$);}
     211           0 :       | '[' error ']'       {$$=-1; YYABORT;}
     212             : ;
     213             : 
     214         830 : in: lvalue '<' '-' expr {$$=newnode(Flistarg,$4,$1,&@$);}
     215             : ;
     216             : 
     217         592 : inseq: in                    {$$=newopcall(OPcompr,$1,-2,&@$);}
     218         147 :      | in ',' expr           {$$=newopcall3(OPcompr,$1,-2,$3,&@$);}
     219          77 :      | in ';' inseq          {$$=newopcall(OPcomprc,$1,$3,&@$);}
     220          14 :      | in ',' expr ';' inseq {$$=newopcall3(OPcomprc,$1,$5,$3,&@$);}
     221             : ;
     222             : 
     223         739 : compr: '[' expr '|' inseq ']' {$$=addcurrexpr($4,$2,&@$);}
     224             : ;
     225             : 
     226      366536 : arg: seq        {$$=$1;}
     227          21 :    | lvalue '[' ".." ']' {$$=newnode(Fvararg,$1,-1,&@$);}
     228        1484 :    | '&' lvalue {$$=newnode(Frefarg,$2,-1,&@$);}
     229         392 :    | '~' lvalue {$$=newnode(Findarg,$2,-1,&@$);}
     230         140 :    | arg error  {if (!pari_once) { yyerrok; } pari_once=1;}  expr
     231         105 :                      {pari_once=0; $$=newopcall(OPcat,$1,$4,&@$);}
     232             : ;
     233             : 
     234      200427 : listarg: arg {$$=$1;}
     235      168006 :        | listarg ',' arg {$$=newnode(Flistarg,$1,$3,&@$);}
     236             : ;
     237             : 
     238      192478 : funcid: KENTRY '(' listarg ')' {$$=newnode(Ffunction,newconst(CSTentry,&@1),$3,&@$);}
     239             : ;
     240             : 
     241       12383 : memberid: expr '.' KENTRY {$$=newnode(Ffunction,newconst(CSTmember,&@3),$1,&@$);}
     242             : ;
     243             : 
     244             : definition: KENTRY '(' listarg ')' '=' seq %prec DEFFUNC
     245        3541 :                                    {$$=newfunc(CSTentry,&@1,$3,$6,&@$);}
     246             :           | expr '.' KENTRY '=' seq %prec DEFFUNC
     247          14 :                                    {$$=newfunc(CSTmember,&@3,newnode(Findarg,$1,-1,&@1),$5,&@$);}
     248        1276 :           | lvalue "->" seq              {$$=newnode(Flambda, $1,$3,&@$);}
     249        4086 :           | '(' listarg ")->" seq        {$$=newnode(Flambda, $2,$4,&@$);}
     250             : ;
     251             : 
     252             : %%

Generated by: LCOV version 1.14