Imported Upstream version 4.4
[platform/upstream/make.git] / tests / scripts / functions / intcmp
1 #                                                                    -*-perl-*-
2 $description = "Test the intcmp function.\n";
3
4 $details = "Try various uses of intcmp and ensure they all give the correct
5 results.\n";
6
7 run_make_test('# Negative
8 n = -10
9 # Zero
10 z = 0
11 # Positive
12 p = 888
13 min = -9223372036854775808
14 max = 9223372036854775807
15 huge = 8857889956778499040639527525992734031025567913257255490371761260681427
16 .RECIPEPREFIX = >
17 all:
18 > @echo 0_1 $(intcmp $n,$n)
19 > @echo 0_2 $(intcmp $z,$z)
20 > @echo 0_3 $(intcmp -$z,$z)
21 > @echo 0_4 $(intcmp $p,$p)
22 > @echo 0_5 $(intcmp $n,$z)
23 > @echo 0_6 $(intcmp $z,$n)
24 > @echo 1_1 $(intcmp $n,$n,$(shell echo lt))
25 > @echo 1_2 $(intcmp $n,$z,$(shell echo lt))
26 > @echo 1_3 $(intcmp $z,$n,$(shell echo lt))
27 > @echo 2_1 $(intcmp $n,$p,lt,ge)
28 > @echo 2_2 $(intcmp $z,$z,lt,ge)
29 > @echo 2_3 $(intcmp $p,$n,lt,ge)
30 > @echo 3_0 $(intcmp $p,$n,lt,eq,)
31 > @echo 3_1 $(intcmp $z,$p,lt,eq,gt)
32 > @echo 3_2 $(intcmp $p,$z,lt,eq,gt)
33 > @echo 3_3 $(intcmp $p,$p,lt,eq,gt)
34 > @echo 4_0 $(intcmp $(min),$(max),lt,eq,gt)
35 > @echo 4_1 $(intcmp $(max),$(min),lt,eq,gt)
36 > @echo 4_2 $(intcmp $(min),$(min),lt,eq,gt)
37 > @echo 4_3 $(intcmp $(max),$(max),lt,eq,gt)
38 > @echo 5_0 $(intcmp -$(huge),$(huge),lt,eq,gt)
39 > @echo 5_1 $(intcmp $(huge),-$(huge),lt,eq,gt)
40 > @echo 5_2 $(intcmp -$(huge),-$(huge),lt,eq,gt)
41 > @echo 5_3 $(intcmp +$(huge),$(huge),lt,eq,gt)
42 ', '', "0_1 -10\n0_2 0\n0_3 0\n0_4 888\n0_5\n0_6\n1_1\n1_2 lt\n1_3\n2_1 lt\n2_2 ge\n2_3 ge\n3_0\n3_1 lt\n3_2 gt\n3_3 eq\n4_0 lt\n4_1 gt\n4_2 eq\n4_3 eq\n5_0 lt\n5_1 gt\n5_2 eq\n5_3 eq\n");
43
44 # Test error conditions
45
46 run_make_test('
47 intcmp-e1: ; @echo $(intcmp 12a,1,foo)
48 intcmp-e2: ; @echo $(intcmp 0,,foo)
49 intcmp-e3: ; @echo $(intcmp -1,)
50 intcmp-e4: ; @echo $(intcmp ,55)',
51               'intcmp-e1',
52               "#MAKEFILE#:2: *** non-numeric first argument to 'intcmp' function: '12a'.  Stop.",
53               512);
54
55 run_make_test(undef,
56               'intcmp-e2',
57               "#MAKEFILE#:3: *** non-numeric second argument to 'intcmp' function: empty value.  Stop.",
58               512);
59
60 run_make_test(undef,
61               'intcmp-e3',
62               "#MAKEFILE#:4: *** non-numeric second argument to 'intcmp' function: empty value.  Stop.",
63               512);
64
65 run_make_test(undef,
66               'intcmp-e4',
67               "#MAKEFILE#:5: *** non-numeric first argument to 'intcmp' function: empty value.  Stop.",
68               512);
69
70
71 # This tells the test driver that the perl test script executed properly.
72 1;