X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fexpressions%2Fparse.at;h=e40a4fe873c3b910c53f8754134d1c1f42714b5e;hb=29d4ab4e8970f0dc4abd8fe18eb37b521cb44efb;hp=31791a41daa62072ab21c0c1a5736d537a8c919f;hpb=0db42c2d683822e1252f17c2c81252a79e618d9c;p=pspp diff --git a/tests/language/expressions/parse.at b/tests/language/expressions/parse.at index 31791a41da..e40a4fe873 100644 --- a/tests/language/expressions/parse.at +++ b/tests/language/expressions/parse.at @@ -1,3 +1,19 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([expression parsing]) AT_SETUP([parse expression with unknown variable crash]) @@ -22,6 +38,72 @@ parse.sps:11: error: Stopping syntax file processing here to avoid a cascade of ]) AT_CLEANUP +AT_SETUP([parsing numeric expression with type mismatch]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1(A). +IF 'foo'. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +"parse.sps:2: error: IF: Type mismatch: expression has string type, but a numeric value is required here." +]) +AT_CLEANUP + +AT_SETUP([parsing string expression with type mismatch]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1(A). +COMPUTE x=1. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +"parse.sps:2: error: COMPUTE: Type mismatch: expression has number type, but a string value is required here." +]) +AT_CLEANUP + +AT_SETUP([parse expression with unknown system variable]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1. +COMPUTE x=$nonexistent. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +parse.sps:2: error: COMPUTE: Unknown system variable $nonexistent. +]) +AT_CLEANUP + +AT_SETUP([parse expression with unknown identifier]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1. +COMPUTE x=y. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +parse.sps:2: error: COMPUTE: Unknown identifier y. +]) +AT_CLEANUP + +AT_SETUP([parse expression with extension function in compatibility mode]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DEBUG EVALUATE/ACOS(0)*0. +]) +AT_CHECK([pspp --testing-mode --syntax=compatible -O format=csv parse.sps], [0], [dnl +parse.sps:1: warning: DEBUG EVALUATE: ACOS(number) is a PSPP extension. +0.00 +]) +AT_CLEANUP + +AT_SETUP([LAG expression following TEMPORARY]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1. +TEMPORARY +COMPUTE y=LAG(x). +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +parse.sps:3: error: COMPUTE: LAG(num_variable) may not appear after TEMPORARY. +]) +AT_CLEANUP + AT_SETUP([parse expression with invalid logical expression]) AT_DATA([parse.sps], [dnl INPUT PROGRAM.