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 Coverage Total Hit
Test: PARI/GP v2.18.1 lcov report (development 31042-0fbe168e69) Lines: 93.4 % 122 114
Test Date: 2026-07-23 17:04:59 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       937503 : %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 eq inseq
      87           28 : %destructor { pari_discarded++; } seq matrix range matrix_index expr exprno lvalue matrixelts matrixeltsno matrixlines arg listarg definition funcid memberid backticks history compr in eq inseq deriv
      88              : %%
      89              : 
      90       937496 : sequence: seq        {$$=$1; (void) pari_nerrs;} /* skip the destructor */
      91              : ;
      92              : 
      93        15186 : seq: /**/ %prec SEQ  {$$=NOARG(@$);}
      94      1330096 :    | expr %prec SEQ  {$$=$1;}
      95        45591 :    | seq ';'         {$$=$1; @$=@1;}
      96        33286 :    | seq ';' expr    {$$=newnode(Fseq,$1,$3,&@$);}
      97              : ;
      98              : 
      99          952 : range: /* */          { $$=newnode(Frange,NORANGE(@$),NORANGE(@$),&@$); }
     100        14567 :      | expr           { $$=newnode(Frange,$1,NORANGE(@$),&@$); }
     101          756 :      | expr ".." expr { $$=newnode(Frange,$1,$3,&@$); }
     102           98 :      | '^' expr       { $$=newnode(Frange,NORANGE(@$),$2,&@$); }
     103              : ;
     104              : 
     105         1756 : matrix_index: '[' range ',' range ']' {$$=newnode(Fmatrix,$2,$4,&@$);}
     106        12861 :             | '[' 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            7 :        | '%' '#' KINTEGER {$$=newopcall(OPhisttime,newintnode(&@3),-1,&@$);}
     118            7 :        | '%' '#' backticks{$$=newopcall(OPhisttime,newnode(Fsmall,-$3,-1,&@$),-1,&@$);}
     119              : ;
     120              : 
     121          175 : deriv: '\'' {$$ = 1;}
     122           42 :      | deriv '\'' {$$ = $1+1;}
     123              : ;
     124              : 
     125     31517468 : expr: KINTEGER %prec INT  {$$=newintnode(&@1);}
     126         6297 :     | KREAL               {$$=newconst(CSTreal,&@$);}
     127            0 :     | '.'                 {$$=newconst(CSTreal,&@$);}
     128            0 :     | KINTEGER '.' KENTRY {$$=newnode(Ffunction,newconst(CSTmember,&@3),
     129              :                                                 newintnode(&@1),&@$);}
     130      3822335 :     | KSTRING       {$$=newconst(CSTstr,&@$);}
     131         3818 :     | '\'' KENTRY   {$$=newconst(CSTquote,&@$);}
     132          112 :     | history           {$$=$1;}
     133          329 :     | expr '(' listarg ')'  {$$=newnode(Fcall,$1,$3,&@$);}
     134       209880 :     | funcid            {$$=$1;}
     135       304016 :     | lvalue %prec LVAL {$$=$1;}
     136     15471306 :     | matrix            {$$=$1;}
     137          872 :     | compr             {$$=$1;}
     138         9386 :     | definition        {$$=$1;}
     139         1246 :     | matrix '=' expr {$$=newnode(Fassign,$1,$3,&@$);}
     140        52456 :     | lvalue '=' expr {$$=newnode(Fassign,$1,$3,&@$);}
     141          190 :     | lvalue "++"     {$$=newopcall(OPpp,$1,-1,&@$);}
     142           28 :     | lvalue "--"     {$$=newopcall(OPss,$1,-1,&@$);}
     143          195 :     | 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          229 :     | lvalue "+="   expr {$$=newopcall(OPpe,$1,$3,&@$);}
     151           63 :     | lvalue "-="   expr {$$=newopcall(OPse,$1,$3,&@$);}
     152          903 :     | '!' expr         {$$=newopcall(OPnb,$2,-1,&@$);}
     153         3895 :     | '#' expr         {$$=newopcall(OPlength,$2,-1,&@$);}
     154          462 :     | expr "||"  expr  {$$=newopcall(OPor,$1,$3,&@$);}
     155          812 :     | expr "&&"  expr  {$$=newopcall(OPand,$1,$3,&@$);}
     156            0 :     | expr '&'   expr  {$$=newopcall(OPand,$1,$3,&@$);}
     157          343 :     | expr "===" expr  {$$=newopcall(OPid,$1,$3,&@$);}
     158        11733 :     | expr "=="  expr  {$$=newopcall(OPeq,$1,$3,&@$);}
     159         2303 :     | expr "!="  expr  {$$=newopcall(OPne,$1,$3,&@$);}
     160          125 :     | expr ">="  expr  {$$=newopcall(OPge,$1,$3,&@$);}
     161          490 :     | expr '>'   expr  {$$=newopcall(OPg,$1,$3,&@$);}
     162          237 :     | expr "<="  expr  {$$=newopcall(OPle,$1,$3,&@$);}
     163         1348 :     | expr '<'   expr  {$$=newopcall(OPl,$1,$3,&@$);}
     164        30443 :     | expr '-'   expr  {$$=newopcall(OPs,$1,$3,&@$);}
     165        59336 :     | expr '+'   expr  {$$=newopcall(OPp,$1,$3,&@$);}
     166          147 :     | expr "<<"  expr  {$$=newopcall(OPsl,$1,$3,&@$);}
     167           21 :     | expr ">>"  expr  {$$=newopcall(OPsr,$1,$3,&@$);}
     168          728 :     | expr '%'   expr  {$$=newopcall(OPmod,$1,$3,&@$);}
     169           28 :     | expr "\\/" expr  {$$=newopcall(OPdr,$1,$3,&@$);}
     170          217 :     | expr '\\'  expr  {$$=newopcall(OPeuc,$1,$3,&@$);}
     171       905638 :     | expr '/'   expr  {$$=newopcall(OPd,$1,$3,&@$);}
     172        61271 :     | expr '*'   expr  {$$=newopcall(OPm,$1,$3,&@$);}
     173           84 :     | '+' expr %prec SIGN {$$=$2;}
     174      9400720 :     | '-' expr %prec SIGN {$$=newopcall(OPn,$2,-1,&@$);}
     175        77652 :     | expr '^' expr {$$=newopcall(OPpow,$1,$3,&@$);}
     176         5089 :     | expr '~' {$$=newopcall(OPtrans,$1,-1,&@$);}
     177          175 :     | expr deriv %prec DERIV {$$=newopcall(OPderivn,$1, newnode(Fsmall,$2,-1,&@$),&@$);}
     178          243 :     | expr '!'  {$$=newopcall(OPfact,$1,-1,&@$);}
     179           28 :     | expr '#'  {$$=newopcall(OPprim,$1,-1,&@$);}
     180         4618 :     | expr matrix_index {$$=newnode(Fmatcoeff,$1,$2,&@$);}
     181        12642 :     | memberid {$$=$1;}
     182            0 :     | expr ':' KENTRY   {$$=newnode(Ftag,$1,0,&@$);}
     183        14289 :     | '(' expr ')' {$$=$2;}
     184              : ;
     185              : 
     186       361880 : lvalue: KENTRY %prec LVAL   {$$=newnode(Fentry,newconst(CSTentry,&@1),-1,&@$);}
     187         9999 :       | lvalue matrix_index {$$=newnode(Fmatcoeff,$1,$2,&@$);}
     188            0 :       | lvalue ':' KENTRY   {$$=newnode(Ftag,$1,newconst(CSTentry,&@2),&@$);}
     189              : ;
     190              : 
     191     34928908 : exprno: expr {$$=$1;}
     192           42 :       | /**/ {$$=NOARG(@$);}
     193              : 
     194     34928950 : matrixeltsno: matrixelts {$$=$1;}
     195            7 :             | /**/ {$$=NOARG(@$);}
     196              : ;
     197              : 
     198     13879751 : matrixelts: expr {$$=$1;}
     199     34928950 :           | matrixeltsno ',' exprno {$$=newnode(Fmatrixelts,$1,$3,&@$);}
     200              : ;
     201              : 
     202         8686 : matrixlines: matrixelts  ';' matrixelts {$$=newnode(Fmatrixlines,$1,$3,&@$);}
     203        20993 :            | matrixlines ';' matrixelts {$$=newnode(Fmatrixlines,$1,$3,&@$);}
     204              : ;
     205              : 
     206      1620479 : matrix: '[' ']'             {$$=newnode(Fvec,-1,-1,&@$);}
     207         1000 :       | '[' expr ".." expr ']' {$$=newopcall(OPrange,$2,$4,&@$);}
     208         1001 :       | '[' ';' ']'         {$$=newnode(Fmat,-1,-1,&@$);}
     209     13841386 :       | '[' matrixelts ']'  {$$=newnode(Fvec,$2,-1,&@$);}
     210         8686 :       | '[' matrixlines ']' {$$=newnode(Fmat,$2,-1,&@$);}
     211              : ;
     212              : 
     213          970 : in: lvalue '<' '-' expr {$$=newnode(Flistarg,$4,$1,&@$);}
     214              : ;
     215              : 
     216            7 : eq: lvalue '=' expr {$$=newnode(Flistarg,$3,$1,&@$);}
     217              : ;
     218              : 
     219          697 : inseq: in                    {$$=newopcall(OPcompr,$1,-2,&@$);}
     220          168 :      | in ',' expr           {$$=newopcall3(OPcompr,$1,-2,$3,&@$);}
     221           91 :      | in ';' inseq          {$$=newopcall(OPcomprc,$1,$3,&@$);}
     222           14 :      | in ',' expr ';' inseq {$$=newopcall3(OPcomprc,$1,$5,$3,&@$);}
     223            0 :      | eq                    {$$=newopcall(OPcompreq,$1,-2,&@$);}
     224            7 :      | eq ',' expr           {$$=newopcall3(OPcompreq,$1,-2,$3,&@$);}
     225            0 :      | eq ';' inseq          {$$=newopcall(OPcompreqc,$1,$3,&@$);}
     226            0 :      | eq ',' expr ';' inseq {$$=newopcall3(OPcompreqc,$1,$5,$3,&@$);}
     227              : ;
     228              : 
     229          872 : compr: '[' expr '|' inseq ']' {$$=addcurrexpr($4,$2,&@$);}
     230              : ;
     231              : 
     232       398400 : arg: seq        {$$=$1;}
     233           21 :    | lvalue '[' ".." ']' {$$=newnode(Fvararg,$1,-1,&@$);}
     234         1540 :    | '&' lvalue {$$=newnode(Frefarg,$2,-1,&@$);}
     235          686 :    | '~' lvalue {$$=newnode(Findarg,$2,-1,&@$);}
     236          153 :    | arg error  {if (!pari_once) { yyerrok; } pari_once=1;}  expr
     237          104 :                      {pari_once=0; $$=newopcall(OPcat,$1,$4,&@$);}
     238              : ;
     239              : 
     240       218186 : listarg: arg {$$=$1;}
     241       182454 :        | listarg ',' arg {$$=newnode(Flistarg,$1,$3,&@$);}
     242              : ;
     243              : 
     244       209880 : funcid: KENTRY '(' listarg ')' {$$=newnode(Ffunction,newconst(CSTentry,&@1),$3,&@$);}
     245              : ;
     246              : 
     247        12642 : memberid: expr '.' KENTRY {$$=newnode(Ffunction,newconst(CSTmember,&@3),$1,&@$);}
     248              : ;
     249              : 
     250              : definition: KENTRY '(' listarg ')' '=' seq %prec DEFFUNC
     251         3842 :                                    {$$=newfunc(CSTentry,&@1,$3,$6,&@$);}
     252              :           | expr '.' KENTRY '=' seq %prec DEFFUNC
     253           14 :                                    {$$=newfunc(CSTmember,&@3,newnode(Findarg,$1,-1,&@1),$5,&@$);}
     254         1409 :           | lvalue "->" seq              {$$=newnode(Flambda, $1,$3,&@$);}
     255         4121 :           | '(' listarg ")->" seq        {$$=newnode(Flambda, $2,$4,&@$);}
     256              : ;
     257              : 
     258              : %%
        

Generated by: LCOV version 2.0-1