summaryrefslogtreecommitdiff
path: root/Windows/spice/tests/regression/parser/xpressn-1.cir
diff options
context:
space:
mode:
Diffstat (limited to 'Windows/spice/tests/regression/parser/xpressn-1.cir')
-rw-r--r--Windows/spice/tests/regression/parser/xpressn-1.cir425
1 files changed, 425 insertions, 0 deletions
diff --git a/Windows/spice/tests/regression/parser/xpressn-1.cir b/Windows/spice/tests/regression/parser/xpressn-1.cir
new file mode 100644
index 00000000..a680633c
--- /dev/null
+++ b/Windows/spice/tests/regression/parser/xpressn-1.cir
@@ -0,0 +1,425 @@
+* 'xpressn-1' check xpressn.c parser
+
+* (exec-spice "ngspice -b %s")
+* (tests-aux-renumber)
+
+* ----------------------------------------
+* arbitrary tests
+
+v1001_t n1001_t 0 '1+2'
+v1002_t n1002_t 0 '1 + 2 '
+v1003_t n1003_t 0 '1+2*3'
+v1004_t n1004_t 0 '(1?2:3)+100'
+v1005_t n1005_t 0 '(1>2?2*4:1+2*3)+100'
+
+v1001_g n1001_g 0 '3'
+v1002_g n1002_g 0 '3'
+v1003_g n1003_g 0 '7'
+v1004_g n1004_g 0 '102'
+v1005_g n1005_g 0 '107'
+
+
+v1006_t n1006_t 0 '1-2.1'
+v1007_t n1007_t 0 '1--1'
+v1008_t n1008_t 0 '5+2/-4'
+
+v1006_g n1006_g 0 '-1.1'
+v1007_g n1007_g 0 '2'
+v1008_g n1008_g 0 '4.5'
+
+
+* ----------------------------------------
+* boolean operators '&&' '||' '!'
+* output: 0.0 or 1.0
+* input: 0.0 is 'false', everything else is 'true'
+
+* ---------------
+* `&&' operator
+
+v1009_t n1009_t 0 '0 && 0'
+v1010_t n1010_t 0 '0 && 1'
+v1011_t n1011_t 0 '1 && 0'
+v1012_t n1012_t 0 '0.1 && 0.2'
+v1013_t n1013_t 0 '-0.1 && 0.2'
+
+v1009_g n1009_g 0 '0'
+v1010_g n1010_g 0 '0'
+v1011_g n1011_g 0 '0'
+v1012_g n1012_g 0 '1'
+v1013_g n1013_g 0 '1'
+
+
+* ---------------
+* `||' operator
+
+v1014_t n1014_t 0 '0 || 0'
+v1015_t n1015_t 0 '0 || 0.1'
+v1016_t n1016_t 0 '-0.1 || 0'
+v1017_t n1017_t 0 '0.1 || -0.2'
+
+v1014_g n1014_g 0 '0'
+v1015_g n1015_g 0 '1'
+v1016_g n1016_g 0 '1'
+v1017_g n1017_g 0 '1'
+
+
+* ---------------
+* `!' operator
+
+v1018_t n1018_t 0 '! 0.0'
+v1019_t n1019_t 0 '! 0.1'
+v1020_t n1020_t 0 '! (-0.1)'
+
+v1018_g n1018_g 0 '1'
+v1019_g n1019_g 0 '0'
+v1020_g n1020_g 0 '0'
+
+
+
+* ----------------------------------------
+* comparison operators
+* output: 0.0 or 1.0
+
+* ----------
+* `>'
+
+v1021_t n1021_t 0 '3 > 2'
+v1022_t n1022_t 0 '2 > 3'
+v1023_t n1023_t 0 '2 > 2'
+
+v1021_g n1021_g 0 '1'
+v1022_g n1022_g 0 '0'
+v1023_g n1023_g 0 '0'
+
+
+* ----------
+* '<'
+
+v1024_t n1024_t 0 '3 < 2'
+v1025_t n1025_t 0 '2 < 3'
+v1026_t n1026_t 0 '2 < 2'
+
+v1024_g n1024_g 0 '0'
+v1025_g n1025_g 0 '1'
+v1026_g n1026_g 0 '0'
+
+
+* ----------
+* '<='
+
+v1027_t n1027_t 0 '3 >= 2'
+v1028_t n1028_t 0 '2 >= 3'
+v1029_t n1029_t 0 '2 >= 2'
+
+v1027_g n1027_g 0 '1'
+v1028_g n1028_g 0 '0'
+v1029_g n1029_g 0 '1'
+
+
+* ----------
+* '>='
+
+v1030_t n1030_t 0 '3 <= 2'
+v1031_t n1031_t 0 '2 <= 3'
+v1032_t n1032_t 0 '2 <= 2'
+
+v1030_g n1030_g 0 '0'
+v1031_g n1031_g 0 '1'
+v1032_g n1032_g 0 '1'
+
+
+* ----------
+* '=='
+
+v1033_t n1033_t 0 '3 == 2'
+v1034_t n1034_t 0 '2 == 3'
+v1035_t n1035_t 0 '2 == 2'
+
+v1033_g n1033_g 0 '0'
+v1034_g n1034_g 0 '0'
+v1035_g n1035_g 0 '1'
+
+
+* ----------
+* '!='
+
+v1036_t n1036_t 0 '3 != 2'
+v1037_t n1037_t 0 '2 != 3'
+v1038_t n1038_t 0 '2 != 2'
+
+v1036_g n1036_g 0 '1'
+v1037_g n1037_g 0 '1'
+v1038_g n1038_g 0 '0'
+
+
+* ----------------------------------------
+* four variants of exponentiation
+
+v1039_t n1039_t 0 '2 ^ 3'
+v1039_g n1039_g 0 '8'
+
+v1040_t n1040_t 0 '2 ** 3'
+v1040_g n1040_g 0 '8'
+
+v1041_t n1041_t 0 'pwr(2,3)'
+v1041_g n1041_g 0 '8'
+
+v1042_t n1042_t 0 'pow(2,3)'
+v1042_g n1042_g 0 '8'
+
+
+* ----------------------------------------
+* ternary 'c ? x : y' operator
+* input: 0.0 is false, everything else is true
+
+v1043_t n1043_t 0 ' 0.1 ? 42 : 43'
+v1044_t n1044_t 0 '-0.1 ? 42 : 43'
+v1045_t n1045_t 0 ' 0.0 ? 42 : 43'
+
+v1043_g n1043_g 0 '42'
+v1044_g n1044_g 0 '42'
+v1045_g n1045_g 0 '43'
+
+* assoziativity
+
+v1046_t n1046_t 0 '1 ? 42 : 1 ? 41 : 40'
+v1047_t n1047_t 0 '1 ? 42 : 0 ? 41 : 40'
+v1048_t n1048_t 0 '0 ? 42 : 1 ? 41 : 40'
+v1049_t n1049_t 0 '0 ? 42 : 0 ? 41 : 40'
+
+v1046_g n1046_g 0 '42'
+v1047_g n1047_g 0 '42'
+v1048_g n1048_g 0 '41'
+v1049_g n1049_g 0 '40'
+
+* --------------------
+* regression tests
+* these failed in the past, due to incorrect transformations in inpcom.c
+
+* was incorrectly transformed --> (3>2)||ternary_fcn((1<4),0.2,0.3)
+v1050_t n1050_t 0 '(3>2)||(1<4) ? 0.2 : 0.3'
+v1050_g n1050_g 0 '0.2'
+
+* was incorrectly transformed --> controlled_exit()
+v1051_t n1051_t 0 '(3>2) ? (3+2)*((2>1)?1:1) : 42'
+v1051_g n1051_g 0 '5'
+
+* was incorrectly transformed --> ternary_fcn((3>2),42,(2*2))3
+v1052_t n1052_t 0 '(3>2) ? 42 : (2*2)+3'
+v1052_g n1052_g 0 '42'
+
+
+* ----------------------------------------
+* functions
+
+v1053_t n1053_t 0 'sin(0.3)'
+v1054_t n1054_t 0 'cos(0.3)'
+v1055_t n1055_t 0 'tan(0.3)'
+v1056_t n1056_t 0 'asin(0.3)'
+v1057_t n1057_t 0 'acos(0.3)'
+v1058_t n1058_t 0 'atan(0.3)'
+v1059_t n1059_t 0 'arctan(0.3)'
+v1060_t n1060_t 0 'sinh(0.3)'
+v1061_t n1061_t 0 'cosh(0.3)'
+v1062_t n1062_t 0 'tanh(0.3)'
+v1063_t n1063_t 0 'asinh(0.3)'
+v1064_t n1064_t 0 'acosh(1.3)'
+v1065_t n1065_t 0 'atanh(0.3)'
+
+v1053_g n1053_g 0 '0.29552020666133955'
+v1054_g n1054_g 0 '0.955336489125606'
+v1055_g n1055_g 0 '0.30933624960962325'
+v1056_g n1056_g 0 '0.3046926540153975'
+v1057_g n1057_g 0 '1.266103672779499'
+v1058_g n1058_g 0 '0.29145679447786704'
+v1059_g n1059_g 0 '0.29145679447786704'
+v1060_g n1060_g 0 '0.3045202934471426'
+v1061_g n1061_g 0 '1.0453385141288605'
+v1062_g n1062_g 0 '0.2913126124515909'
+v1063_g n1063_g 0 '0.2956730475634223'
+v1064_g n1064_g 0 '0.7564329108569595'
+v1065_g n1065_g 0 '0.3095196042031116'
+
+* ----------
+
+v1066_t n1066_t 0 'exp(2.0)'
+v1067_t n1067_t 0 'exp(-2.0)'
+
+v1066_g n1066_g 0 '7.38905609893065'
+v1067_g n1067_g 0 '0.1353352832366127'
+
+* ----------
+
+v1068_t n1068_t 0 'log(2.0)'
+v1069_t n1069_t 0 'log(0.5)'
+
+v1068_g n1068_g 0 '0.6931471805599453'
+v1069_g n1069_g 0 '-0.6931471805599453'
+
+v1070_t n1070_t 0 'ln(2.0)'
+v1071_t n1071_t 0 'ln(0.5)'
+
+v1070_g n1070_g 0 '0.6931471805599453'
+v1071_g n1071_g 0 '-0.6931471805599453'
+
+* ----------
+
+v1072_t n1072_t 0 'sqrt(2.0)'
+v1072_g n1072_g 0 '1.4142135623730951'
+
+v1073_t n1073_t 0 'sqr(2.0)'
+v1073_g n1073_g 0 '4.0'
+
+
+* ----------------------------------------
+* functions
+
+v1074_t n1074_t 0 'abs(2.0)'
+v1075_t n1075_t 0 'abs(-2.0)'
+
+v1074_g n1074_g 0 '2'
+v1075_g n1075_g 0 '2'
+
+
+v1076_t n1076_t 0 'sgn(2.0)'
+v1077_t n1077_t 0 'sgn(0.0)'
+v1078_t n1078_t 0 'sgn(-2.0)'
+
+v1076_g n1076_g 0 '1'
+v1077_g n1077_g 0 '0'
+v1078_g n1078_g 0 '-1'
+
+
+v1079_t n1079_t 0 'int(2.1)'
+v1080_t n1080_t 0 'int(1.9)'
+v1081_t n1081_t 0 'int(0)'
+v1082_t n1082_t 0 'int(-1.9)'
+v1083_t n1083_t 0 'int(-2.1)'
+
+v1079_g n1079_g 0 '2'
+v1080_g n1080_g 0 '1'
+v1081_g n1081_g 0 '0'
+v1082_g n1082_g 0 '-1'
+v1083_g n1083_g 0 '-2'
+
+
+v1084_t n1084_t 0 'nint(2.6)'
+v1085_t n1085_t 0 'nint(2.5)'
+v1086_t n1086_t 0 'nint(2.4)'
+v1087_t n1087_t 0 'nint(1.6)'
+v1088_t n1088_t 0 'nint(1.5)'
+v1089_t n1089_t 0 'nint(1.4)'
+v1090_t n1090_t 0 'nint(0.6)'
+v1091_t n1091_t 0 'nint(0.5)'
+v1092_t n1092_t 0 'nint(0.4)'
+v1093_t n1093_t 0 'nint(0)'
+v1094_t n1094_t 0 'nint(-0.4)'
+v1095_t n1095_t 0 'nint(-0.5)'
+v1096_t n1096_t 0 'nint(-0.6)'
+v1097_t n1097_t 0 'nint(-1.4)'
+v1098_t n1098_t 0 'nint(-1.5)'
+v1099_t n1099_t 0 'nint(-1.6)'
+v1100_t n1100_t 0 'nint(-2.4)'
+v1101_t n1101_t 0 'nint(-2.5)'
+v1102_t n1102_t 0 'nint(-2.6)'
+
+v1084_g n1084_g 0 '3'
+v1085_g n1085_g 0 '2'
+v1086_g n1086_g 0 '2'
+v1087_g n1087_g 0 '2'
+v1088_g n1088_g 0 '2'
+v1089_g n1089_g 0 '1'
+v1090_g n1090_g 0 '1'
+v1091_g n1091_g 0 '0'
+v1092_g n1092_g 0 '0'
+v1093_g n1093_g 0 '0'
+v1094_g n1094_g 0 '0'
+v1095_g n1095_g 0 '0'
+v1096_g n1096_g 0 '-1'
+v1097_g n1097_g 0 '-1'
+v1098_g n1098_g 0 '-2'
+v1099_g n1099_g 0 '-2'
+v1100_g n1100_g 0 '-2'
+v1101_g n1101_g 0 '-2'
+v1102_g n1102_g 0 '-3'
+
+
+v1103_t n1103_t 0 'floor(2.1)'
+v1104_t n1104_t 0 'floor(1.9)'
+v1105_t n1105_t 0 'floor(0)'
+v1106_t n1106_t 0 'floor(-1.9)'
+v1107_t n1107_t 0 'floor(-2.1)'
+
+v1103_g n1103_g 0 '2'
+v1104_g n1104_g 0 '1'
+v1105_g n1105_g 0 '0'
+v1106_g n1106_g 0 '-2'
+v1107_g n1107_g 0 '-3'
+
+
+v1108_t n1108_t 0 'ceil(2.1)'
+v1109_t n1109_t 0 'ceil(1.9)'
+v1110_t n1110_t 0 'ceil(0)'
+v1111_t n1111_t 0 'ceil(-1.9)'
+v1112_t n1112_t 0 'ceil(-2.1)'
+
+v1108_g n1108_g 0 '3'
+v1109_g n1109_g 0 '2'
+v1110_g n1110_g 0 '0'
+v1111_g n1111_g 0 '-1'
+v1112_g n1112_g 0 '-2'
+
+
+* ----------------------------------------
+* min(a,b) max(a,b)
+
+v1113_t n1113_t 0 'min(1.1, 2.1)'
+v1114_t n1114_t 0 'min(2.1, 1.1)'
+
+v1113_g n1113_g 0 '1.1'
+v1114_g n1114_g 0 '1.1'
+
+
+v1115_t n1115_t 0 'max(1.1, 2.1)'
+v1116_t n1116_t 0 'max(2.1, 1.1)'
+
+v1115_g n1115_g 0 '2.1'
+v1116_g n1116_g 0 '2.1'
+
+
+* ----------------------------------------
+
+.control
+
+define mismatch(a,b,err) abs(a-b)>err
+
+op
+
+let total_count = 0
+let fail_count = 0
+
+let tests = 1001 + vector(116)
+
+foreach n $&tests
+ set n_test = "n{$n}_t"
+ set n_gold = "n{$n}_g"
+ if mismatch(v($n_test), v($n_gold), 1e-9)
+ let v_test = v($n_test)
+ let v_gold = v($n_gold)
+ echo "ERROR, test failure, v($n_test) = $&v_test but should be $&v_gold"
+ let fail_count = fail_count + 1
+ end
+ let total_count = total_count + 1
+end
+
+if fail_count > 0
+ echo "ERROR: $&fail_count of $&total_count tests failed"
+ quit 1
+else
+ echo "INFO: $&fail_count of $&total_count tests failed"
+ quit 0
+end
+
+.endc
+
+.end