X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=tests%2Flanguage%2Fexpressions%2Fparse.at;h=02b713f8b96aad762efa8cf8c5b1f60143639de1;hb=76e0b3df102f54672f8d4dfcc19c144e52a8ff4e;hp=eadc30dd74afdd39bddcf980de5b049f92b3eaf9;hpb=5dbf5abcbed01f04422d4dead1c0ae0bb7efde4f;p=pspp diff --git a/tests/language/expressions/parse.at b/tests/language/expressions/parse.at index eadc30dd74..02b713f8b9 100644 --- a/tests/language/expressions/parse.at +++ b/tests/language/expressions/parse.at @@ -1,16 +1,16 @@ dnl PSPP - a program for statistical analysis. dnl Copyright (C) 2017 Free Software Foundation, Inc. -dnl +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 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 dnl You should have received a copy of the GNU General Public License dnl along with this program. If not, see . dnl @@ -38,6 +38,94 @@ parse.sps:11: error: Stopping syntax file processing here to avoid a cascade of ]) AT_CLEANUP +AT_SETUP([parsing boolean 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 boolean value is required here." +]) +AT_CLEANUP + +AT_SETUP([parsing numeric expression with type mismatch]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1. +COMPUTE x='foo'. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +"parse.sps:2: error: COMPUTE: 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([assigning string expression to new variable]) +AT_KEYWORDS([expression negative]) +AT_DATA([parse.sps], [dnl +DATA LIST NOTABLE/x 1(A). +COMPUTE y='a'. +]) +AT_CHECK([pspp -O format=csv parse.sps], [1], [dnl +"parse.sps:2: error: COMPUTE: This command tries to create a new variable y by assigning a string value to it, but this is not supported. Use the STRING command to create the new variable with the correct width before assigning to it, e.g. STRING y(A20)." +]) +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.