1dnl $NetBSD: math.m4,v 1.2 2005/10/06 17:38:09 drochner Exp $ 2dnl FreeBSD: /repoman/r/ncvs/src/usr.bin/m4/TEST/math.m4,v 1.1 2004/05/01 03:27:05 smkelly Exp 3dnl A regression test for m4 C operators (ksb,petef) 4dnl If you think you have a short-circuiting m4, run us m4 -DSHORCIRCUIT=yes 5dnl 6dnl first level of precedence 7ifelse(eval(-7),-7,,`failed - 8')dnl 9ifelse(eval(- -2),2,,`failed - 10')dnl 11ifelse(eval(!0),1,,`failed ! 12')dnl 13ifelse(eval(!7),0,,`failed ! 14')dnl 15ifelse(eval(~-1),0,,`failed ~ 16')dnl 17dnl next level of precedence 18ifelse(eval(3*5),15,,`failed * 19')dnl 20ifelse(eval(3*0),0,,`failed * 21')dnl 22ifelse(eval(11/2),5,,`failed / 23')dnl 24ifelse(eval(1/700),0,,`failed / 25')dnl 26ifelse(eval(10%5),0,,`failed % 27')dnl 28ifelse(eval(2%5),2,,`failed % 29')dnl 30ifelse(eval(2%-1),0,,`failed % 31')dnl 32dnl next level of precedence 33ifelse(eval(2+2),4,,`failed + 34')dnl 35ifelse(eval(2+-2),0,,`failed + 36')dnl 37ifelse(eval(2- -2),4,,`failed - 38')dnl 39ifelse(eval(2-2),0,,`failed - 40')dnl 41dnl next level of precedence 42ifelse(eval(1<<4),16,,`failed << 43')dnl 44ifelse(eval(16>>4),1,,`failed >> 45')dnl 46dnl next level of precedence 47ifelse(eval(4<4),0,,`failed < 48')dnl 49ifelse(eval(4<5),1,,`failed < 50')dnl 51ifelse(eval(4<3),0,,`failed < 52')dnl 53ifelse(eval(4>4),0,,`failed > 54')dnl 55ifelse(eval(4>5),0,,`failed > 56')dnl 57ifelse(eval(4>3),1,,`failed > 58')dnl 59ifelse(eval(4<=4),1,,`failed <= 60')dnl 61ifelse(eval(4<=5),1,,`failed <= 62')dnl 63ifelse(eval(4<=3),0,,`failed <= 64')dnl 65ifelse(eval(4>=4),1,,`failed >= 66')dnl 67ifelse(eval(4>=5),0,,`failed >= 68')dnl 69ifelse(eval(4>=3),1,,`failed >= 70')dnl 71dnl next level of precedence 72ifelse(eval(1==1),1,,`failed == 73')dnl 74ifelse(eval(1==-1),0,,`failed == 75')dnl 76ifelse(eval(1!=1),0,,`failed != 77')dnl 78ifelse(eval(1!=2),1,,`failed != 79')dnl 80dnl next level of precedence 81ifelse(eval(3&5),1,,`failed & 82')dnl 83ifelse(eval(8&7),0,,`failed & 84')dnl 85dnl next level of precedence 86ifelse(eval(1^1),0,,`failed ^ 87')dnl 88ifelse(eval(21^5),16,,`failed ^ 89')dnl 90dnl next level of precedence 91ifelse(eval(1|1),1,,`failed | 92')dnl 93ifelse(eval(21|5),21,,`failed | 94')dnl 95ifelse(eval(100|1),101,,`failed | 96')dnl 97dnl next level of precedence 98ifelse(eval(1&&1),1,,`failed && 99')dnl 100ifelse(eval(0&&1),0,,`failed && 101')dnl 102ifelse(eval(1&&0),0,,`failed && 103')dnl 104ifelse(SHORTCIRCUIT,`yes',`ifelse(eval(0&&10/0),0,,`failed && shortcircuit 105')')dnl 106dnl next level of precedence 107ifelse(eval(1||1),1,,`failed || 108')dnl 109ifelse(eval(1||0),1,,`failed || 110')dnl 111ifelse(eval(0||0),0,,`failed || 112')dnl 113ifelse(SHORTCIRCUIT,`yes',`ifelse(eval(1||10/0),1,,`failed || shortcircuit 114')')dnl 115dnl next level of precedence 116ifelse(eval(0 ? 2 : 5),5,,`failed ?: 117')dnl 118ifelse(eval(1 ? 2 : 5),2,,`failed ?: 119')dnl 120ifelse(SHORTCIRCUIT,`yes',`ifelse(eval(0 ? 10/0 : 7),7,,`failed ?: shortcircuit 121')')dnl 122ifelse(SHORTCIRCUIT,`yes',`ifelse(eval(1 ? 7 : 10/0),7,,`failed ?: shortcircuit 123')')dnl 124dnl operator precedence 125ifelse(eval(!0*-2),-2,,`precedence wrong, ! * 126')dnl 127ifelse(eval(~8/~2),3,,`precedence wrong ~ / 128')dnl 129ifelse(eval(~-20%7),5,,`precedence wrong ~ % 130')dnl 131ifelse(eval(3*2+100),106,,`precedence wrong * + 132')dnl 133ifelse(eval(3+2*100),203,,`precedence wrong + * 134')dnl 135ifelse(eval(2%5-6/3),0,,`precedence wrong % - 136')dnl 137ifelse(eval(2/5-5%3),-2,,`precedence wrong / - 138')dnl 139ifelse(eval(2+5%5+1),3,,`precedence wrong % + 140')dnl 141ifelse(eval(7+9<<1),32,,`precedence wrong + << 142')dnl 143ifelse(eval(35-3>>2),8,,`precedence wrong - >> 144')dnl 145ifelse(eval(9<10<<5),1,,`precedence wrong << < 146')dnl 147ifelse(eval(9>10<<5),0,,`precedence wrong << > 148')dnl 149ifelse(eval(32>>2<32),1,,`precedence wrong >> < 150')dnl 151ifelse(eval(9<=10<<5),1,,`precedence wrong << < 152')dnl 153ifelse(eval(5<<1<=20>>1),1,,`precedence wrong << <= 154')dnl 155ifelse(eval(5<<1>=20>>1),1,,`precedence wrong << >= 156')dnl 157ifelse(eval(0<7==5>=5),1,,`precedence wrong < == 158')dnl 159ifelse(eval(0<7!=5>=5),0,,`precedence wrong < != 160')dnl 161ifelse(eval(0>7==5>=5),0,,`precedence wrong > == 162')dnl 163ifelse(eval(0>7!=5>=5),1,,`precedence wrong > != 164')dnl 165ifelse(eval(1&7==7),1,,`precedence wrong & == 166')dnl 167ifelse(eval(0&7!=6),0,,`precedence wrong & != 168')dnl 169ifelse(eval(9&1|5),5,,`precedence wrong & | 170')dnl 171ifelse(eval(9&1^5),4,,`precedence wrong & ^ 172')dnl 173ifelse(eval(9^1|5),13,,`precedence wrong ^ | 174')dnl 175ifelse(eval(5|0&&1),1,,`precedence wrong | && 176')dnl 177ifelse(eval(5&&0||0&&5||5),1,,`precedence wrong && || 178')dnl 179ifelse(eval(0 || 1 ? 0 : 1),0,,`precedence wrong || ?: 180')dnl 181ifelse(eval(5&&(0||0)&&(5||5)),0,,`precedence wrong || parens 182')dnl 183