]> git.ipfire.org Git - thirdparty/bird.git/blobdiff - filter/test.conf
Filter: Add bytestring type
[thirdparty/bird.git] / filter / test.conf
index 2a5a2d987fa1d40c3ed98eb6ca7a05cdb9109812..c014dadd52c872b95c4e1de0181e9ad0897c5647 100644 (file)
@@ -38,15 +38,26 @@ bt_test_same(onef, onef, 1);
 bt_test_same(onef, oneg, 1);
 bt_test_same(onef, twof, 0);
 
+/*
+ *     Testing filter corner cases
+ *     ---------------------------
+ */
+
+function t_nothing() {}
+bt_test_suite(t_nothing, "Testing nothing");
+
+function t_metanothing() { t_nothing(); }
+bt_test_suite(t_metanothing, "Testing meta nothing");
+
+
 /*
  *     Testing boolean expressions
  *     ---------------------------
  */
 
 function t_bool()
-bool b;
 {
-       b = true;
+       bool b = true;
        bt_assert(b);
        bt_assert(!!b);
 
@@ -77,17 +88,24 @@ bt_test_suite(t_bool, "Testing boolean expressions");
  *     ----------------
  */
 
+function aux_t_int(int t; int u)
+{
+       case t {
+               1: {}
+               else: {}
+       }
+}
+
 define four = 4;
 define xyzzy = (120+10);
 define '1a-a1' = (xyzzy-100);
 
 function t_int()
-int i;
 {
        bt_assert(xyzzy = 130);
        bt_assert('1a-a1' = 30);
 
-       i = four;
+       int i = four;
        i = 12*100 + 60/2 + i;
        i = (i + 0);
        bt_assert(i = 1234);
@@ -111,6 +129,21 @@ int i;
        bt_assert(!(i = 4));
        bt_assert(1 <= 1);
        bt_assert(!(1234 < 1234));
+
+       case i {
+               4200000000: bt_assert(true);
+               else: bt_assert(false);
+       }
+
+       case four {
+               4: bt_assert(true);
+               else: bt_assert(false);
+       }
+
+       aux_t_int(1, 2);
+       aux_t_int(1, 3);
+       aux_t_int(2, 3);
+       aux_t_int(2, 2);
 }
 
 bt_test_suite(t_int, "Testing integers");
@@ -128,14 +161,19 @@ define is2 = [(17+2), 17, 15, 11, 8, 5, 3, 2];
 define is3 = [5, 17, 2, 11, 8, 15, 3, 19];
 
 function t_int_set()
-int set is;
 {
+       int set is = [];
+       bt_assert(is = []);
+       bt_assert(0 !~ is);
+
        bt_assert(1 ~ [1,2,3]);
        bt_assert(5 ~ [1..20]);
        bt_assert(2 ~ [ 1, 2, 3 ]);
        bt_assert(5 ~ [ 4 .. 7 ]);
        bt_assert(1 !~ [ 2, 3, 4 ]);
        bt_assert(999 !~ [ 666, 333 ]);
+       bt_assert(1 !~ []);
+       bt_assert(1 !~ is);
 
        is = [ 2, 3, 4, 7..11 ];
        bt_assert(10 ~ is);
@@ -170,6 +208,7 @@ int set is;
        bt_assert([1,4..10,20] = [1,4..10,20]);
 
        bt_assert(format([ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]) = "[1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]");
+       bt_assert(format([]) = "[]");
 }
 
 bt_test_suite(t_int_set, "Testing sets of integers");
@@ -183,9 +222,8 @@ bt_test_suite(t_int_set, "Testing sets of integers");
  */
 
 function t_string()
-string st;
 {
-       st = "Hello";
+       string st = "Hello";
        bt_assert(format(st) = "Hello");
        bt_assert(st ~ "Hell*");
        bt_assert(st ~ "?ello");
@@ -199,6 +237,36 @@ bt_test_suite(t_string, "Testing string matching");
 
 
 
+/*
+ *     Testing bytestings
+ *     ------------------
+ */
+
+function t_bytestring()
+{
+       bytestring bs1 = hex:;
+       bytestring bs2 = hex:0112233445566778899aabbccddeeff0;
+
+       bt_assert(format(bs1) = "");
+       bt_assert(format(bs2) = "01:12:23:34:45:56:67:78:89:9a:ab:bc:cd:de:ef:f0");
+       bt_assert(hex:01:12:23:34:45:56:67:78:89:9a:ab:bc:cd:de:ef:f0 = bs2);
+       bt_assert(01:12:23:34:45:56:67:78:89:9a:ab:bc:cd:de:ef:f0 = bs2);
+       bt_assert(0112233445566778899aabbccddeeff0 = bs2);
+       bt_assert(hex:01234567 = hex:01:23:45:67);
+       bt_assert(hex:0123456789abcdef != bs2);
+       bt_assert(hex:0123456789abcdef != hex:0123);
+       bt_assert(format(hex:0123456789abcdef) = "01:23:45:67:89:ab:cd:ef");
+       bt_assert(from_hex(" ") = bs1);
+       bt_assert(from_hex("01:12:23:34:45:56:67:78:89:9a:ab:bc:cd:de:ef:f0") = bs2);
+       bt_assert(from_hex(format(bs2)) = bs2);
+       bt_assert(from_hex(" 0112:23-34455667 78-89 - 9a-ab bc:cd : de:eff0 ") = bs2);
+}
+
+bt_test_suite(t_bytestring, "Testing bytestrings");
+
+
+
+
 /*
  *     Testing pairs
  *     -------------
@@ -210,9 +278,8 @@ function 'mkpair-a'(int a)
 }
 
 function t_pair()
-pair pp;
 {
-       pp = (1, 2);
+       pair pp = (1, 2);
        bt_assert(format(pp) = "(1,2)");
        bt_assert((1,2) = pp);
        bt_assert((1,1+1) = pp);
@@ -233,10 +300,11 @@ bt_test_suite(t_pair, "Testing pairs");
  */
 
 function t_pair_set()
-pair pp;
-pair set ps;
 {
-       pp = (1, 2);
+       pair pp = (1, 2);
+       pair set ps = [];
+       bt_assert(pp !~ ps);
+
        ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)];
        bt_assert(format(ps) = "[(1,2), (3,4)..(4,8), (5,0)..(5,65535), (6,3)..(6,6)]");
        bt_assert(pp ~ ps);
@@ -253,6 +321,7 @@ pair set ps;
        bt_assert((6,6+one) !~ ps);
        bt_assert(((one+6),2) !~ ps);
        bt_assert((1,1) !~ ps);
+       bt_assert(pp !~ []);
 
        ps = [(20..150, 200..300), (50100..50200, 1000..50000), (*, 5+5)];
        bt_assert((100,200) ~ ps);
@@ -304,6 +373,7 @@ quad qq;
        qq = 1.2.3.4;
        bt_assert(qq ~ [1.2.3.4, 5.6.7.8]);
        bt_assert(qq !~ [1.2.1.1, 1.2.3.5]);
+       bt_assert(qq !~ []);
 }
 
 bt_test_suite(t_quad_set, "Testing sets of quads");
@@ -384,6 +454,7 @@ ip set ips;
 
        bt_assert(1.2.3.4 !~ [ 1.2.3.3, 1.2.3.5 ]);
        bt_assert(1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ]);
+       bt_assert(1.2.3.4 !~ []);
 }
 
 bt_test_suite(t_ip_set, "Testing sets of ip address");
@@ -472,13 +543,34 @@ function test_pxset(prefix set pxs)
        bt_assert(1.0.0.0/8 ~ [ 1.0.0.0/8+ ]);
        bt_assert(1.0.0.0/9 !~ [ 1.0.0.0/8- ]);
        bt_assert(1.2.0.0/17 !~ [ 1.0.0.0/8{ 15 , 16 } ]);
+       bt_assert(net10 !~ []);
 
        bt_assert([ 10.0.0.0/8{ 15 , 17 } ] = [ 10.0.0.0/8{ 15 , 17 } ]);
 }
 
+function test_empty_pxset(prefix set pxs)
+int set s0;
+prefix set s1;
+{
+       s0 = [];
+       s1 = [];
+       bt_assert(pxs != s0);
+       bt_assert(pxs = s1);
+       bt_assert(pxs = []);
+}
+
 function t_prefix_set()
 prefix set pxs;
 {
+       pxs = [];
+       bt_assert(format(pxs) = "[]");
+       bt_assert(pxs = []);
+       bt_assert(1.2.0.0/16 !~ []);
+       bt_assert(1.2.0.0/16 !~ pxs);
+
+       test_empty_pxset([]);
+       test_empty_pxset(pxs);
+
        pxs = [ 1.2.0.0/16, 1.4.0.0/16+, 44.66.88.64/30{24,28}, 12.34.56.0/24{8,16} ];
        bt_assert(format(pxs) = "[1.2.0.0/16{0.1.0.0}, 1.4.0.0/16{0.1.255.255}, 12.34.0.0/16{1.255.0.0}, 44.66.88.64/28{0.0.1.240}]");
 
@@ -503,10 +595,10 @@ prefix set pxs;
        bt_assert(format([ 0.0.0.0/0 ]) = "[0.0.0.0/0]");
        bt_assert(format([ 10.10.0.0/32 ]) = "[10.10.0.0/32{0.0.0.1}]");
        bt_assert(format([ 10.10.0.0/17 ]) = "[10.10.0.0/17{0.0.128.0}]");
-       bt_assert(format([ 10.10.0.0/17{17,19} ]) = "[10.10.0.0/17{0.0.224.0}]"); # 224 = 128+64+32
+       bt_assert(format([ 10.10.0.0/17{17,19} ]) = "[10.10.0.0/17{0.0.224.0}]"); # 224 = 128+64+32
        bt_assert(format([ 10.10.128.0/17{18,19} ]) = "[10.10.128.0/18{0.0.96.0}, 10.10.192.0/18{0.0.96.0}]"); # 96 = 64+32
-       bt_assert(format([ 10.10.64.0/18- ]) = "[0.0.0.0/0, 0.0.0.0/1{128.0.0.0}, 0.0.0.0/2{64.0.0.0}, 0.0.0.0/3{32.0.0.0}, 10.10.0.0/16{255.255.0.0}, 10.10.0.0/17{0.0.128.0}, 10.10.64.0/18{0.0.64.0}]");
-       bt_assert(format([ 10.10.64.0/18+ ]) = "[10.10.64.0/18{0.0.96.0}, 10.10.64.0/20{0.0.31.255}, 10.10.80.0/20{0.0.31.255}, 10.10.96.0/20{0.0.31.255}, 10.10.112.0/20{0.0.31.255}]");
+       bt_assert(format([ 10.10.64.0/18- ]) = "[0.0.0.0/0, 0.0.0.0/1{128.0.0.0}, 0.0.0.0/2{64.0.0.0}, 0.0.0.0/3{32.0.0.0}, 10.10.0.0/16{255.255.0.0}, 10.10.0.0/17{0.0.128.0}, 10.10.64.0/18{0.0.64.0}]");
+       bt_assert(format([ 10.10.64.0/18+ ]) = "[10.10.64.0/18{0.0.96.0}, 10.10.64.0/20{0.0.31.255}, 10.10.80.0/20{0.0.31.255}, 10.10.96.0/20{0.0.31.255}, 10.10.112.0/20{0.0.31.255}]");
 
        bt_assert(format([ 10.10.160.0/19 ]) = "[10.10.160.0/19{0.0.32.0}]");
        bt_assert(format([ 10.10.160.0/19{19,22} ]) = "[10.10.160.0/19{0.0.32.0}, 10.10.160.0/20{0.0.28.0}, 10.10.176.0/20{0.0.28.0}]"); # 28 = 16+8+4
@@ -518,10 +610,10 @@ prefix set pxs;
        bt_assert(format([ 11:22:33:44::/64+ ]) = "[11:22:33:44::/64{::1:ffff:ffff:ffff:ffff}]");
 
        bt_assert(format([ 11:22:33:44::/65 ]) = "[11:22:33:44::/65{::8000:0:0:0}]");
-       bt_assert(format([ 11:22:33:44::/65{65,67} ]) = "[11:22:33:44::/65{::e000:0:0:0}]"); # e = 8+4+2
+       bt_assert(format([ 11:22:33:44::/65{65,67} ]) = "[11:22:33:44::/65{::e000:0:0:0}]"); # e = 8+4+2
        bt_assert(format([ 11:22:33:44:8000::/65{66,67} ]) = "[11:22:33:44:8000::/66{::6000:0:0:0}, 11:22:33:44:c000::/66{::6000:0:0:0}]"); # 6 = 4+2
-       bt_assert(format([ 11:22:33:44:4000::/66- ]) = "[::/0, ::/1{8000::}, ::/2{4000::}, ::/3{2000::}, 11:22:33:44::/64{ffff:ffff:ffff:ffff::}, 11:22:33:44::/65{::8000:0:0:0}, 11:22:33:44:4000::/66{::4000:0:0:0}]");
-       bt_assert(format([ 11:22:33:44:4000::/66+ ]) = "[11:22:33:44:4000::/66{::6000:0:0:0}, 11:22:33:44:4000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:5000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:6000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:7000::/68{::1fff:ffff:ffff:ffff}]");
+       bt_assert(format([ 11:22:33:44:4000::/66- ]) = "[::/0, ::/1{8000::}, ::/2{4000::}, ::/3{2000::}, 11:22:33:44::/64{ffff:ffff:ffff:ffff::}, 11:22:33:44::/65{::8000:0:0:0}, 11:22:33:44:4000::/66{::4000:0:0:0}]");
+       bt_assert(format([ 11:22:33:44:4000::/66+ ]) = "[11:22:33:44:4000::/66{::6000:0:0:0}, 11:22:33:44:4000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:5000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:6000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:7000::/68{::1fff:ffff:ffff:ffff}]");
        bt_assert(format([ 11:22:33:44:c000::/67 ]) = "[11:22:33:44:c000::/67{::2000:0:0:0}]");
        bt_assert(format([ 11:22:33:44:c000::/67{67,71} ]) = "[11:22:33:44:c000::/67{::2000:0:0:0}, 11:22:33:44:c000::/68{::1e00:0:0:0}, 11:22:33:44:d000::/68{::1e00:0:0:0}]");
        bt_assert(format([ 11:22:33:44:c000::/67+ ]) = "[11:22:33:44:c000::/67{::2000:0:0:0}, 11:22:33:44:c000::/68{::1fff:ffff:ffff:ffff}, 11:22:33:44:d000::/68{::1fff:ffff:ffff:ffff}]");
@@ -563,6 +655,12 @@ bt_test_suite(t_prefix6, "Testing prefix IPv6");
 function t_prefix6_set()
 prefix set pxs;
 {
+       pxs = [];
+       bt_assert(format(pxs) = "[]");
+       bt_assert(pxs = []);
+       bt_assert(12::34/128 !~ []);
+       bt_assert(12::34/128 !~ pxs);
+
        bt_assert(1180::/16 ~ [ 1100::/8{15, 17} ]);
        bt_assert(12::34 = 12::34);
        bt_assert(12::34 ~ [ 12::33..12::35 ]);
@@ -680,6 +778,7 @@ int set set12;
        bt_assert(3 ~ p2);
        bt_assert(p2 ~ [2, 10..20]);
        bt_assert(p2 ~ [4, 10..20]);
+       bt_assert(p2 !~ []);
 
        p2 = prepend(p2, 5);
        bt_assert(p2 !~ pm1);
@@ -690,6 +789,8 @@ int set set12;
        bt_assert(p2 ~ [= 5 [2, 4, 6] 3 [1..2] 1 =]);
        bt_assert(p2 ~ [= 5 set35 3 set12 set12 =]);
        bt_assert(p2 ~ mkpath(5, 4));
+       bt_assert(p2 ~ [= * [3] * =]);
+       bt_assert(p2 !~ [= * [] * =]);
 
        bt_assert(p2.len = 5);
        bt_assert(p2.first = 5);
@@ -698,6 +799,10 @@ int set set12;
        bt_assert(p2.len = 5);
        bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 1), 2), 4), 5));
        bt_assert(filter(p2, [1..3]) = prepend(prepend(prepend(+empty+, 1), 2), 3));
+       bt_assert(delete(p2, []) = p2);
+       bt_assert(filter(p2, []) = +empty+);
+       bt_assert(delete(prepend(prepend(+empty+, 0), 1), []) = prepend(prepend(+empty+, 0), 1));
+       bt_assert(filter(prepend(prepend(+empty+, 0), 1), []) = +empty+);
 
        p2 = prepend( + empty +, 5 );
        p2 = prepend( p2, 4 );
@@ -717,6 +822,15 @@ int set set12;
        bt_assert(delete(p2, [4..5]) = prepend(prepend(prepend(prepend(+empty+, 3), 3), 2), 1));
 
        bt_assert(format([= 1 2+ 3 =]) = "[= 1 2 + 3 =]");
+
+       # iteration over path
+       int x = 0;
+       int y = 0;
+       for int i in p2 do {
+           x = x + i;
+           y = y + x;
+       }
+       bt_assert(x = 18 && y = 50);
 }
 
 bt_test_suite(t_path, "Testing paths");
@@ -758,6 +872,7 @@ clist r;
        bt_assert(l ~ [(2,2..3)]);
        bt_assert(l ~ [(1,1..2)]);
        bt_assert(l ~ [(1,1)..(1,2)]);
+       bt_assert(l !~ []);
 
        l = add(l, (2,5));
        l = add(l, (5,one));
@@ -795,6 +910,9 @@ clist r;
        bt_assert(l !~ [(*,(one+6))]);
        bt_assert(l !~ [(*, (one+one+one))]);
 
+       bt_assert(delete(l, []) = l);
+       bt_assert(filter(l, []) = -empty-);
+
        l = delete(l, [(*,(one+onef(3)))]);
        l = delete(l, [(*,(4+one))]);
        bt_assert(l = add(-empty-, (3,1)));
@@ -839,6 +957,12 @@ clist r;
        bt_assert(format(r) = "(clist (2,1) (1,3) (2,2) (3,1) (2,3))");
        bt_assert(r.min = (1,3));
        bt_assert(r.max = (3,1));
+
+       # iteration over clist
+       int x = 0;
+       for pair c in r do
+           x = x + c.asn * c.asn * c.data;
+       bt_assert(x = 36);
 }
 
 bt_test_suite(t_clist, "Testing lists of communities");
@@ -912,11 +1036,15 @@ eclist r;
        bt_assert((ro, 10.20.30.40, 100) !~ el);
        bt_assert(el !~ [(rt, 10, 35..40)]);
        bt_assert(el !~ [(ro, 10, *)]);
+       bt_assert(el !~ []);
 
        el = add(el, (rt, 10, 40));
        el2 = filter(el, [(rt, 10, 20..40)] );
        el2 = add(el2, (rt, 10, 50));
 
+       bt_assert(delete(el, []) = el);
+       bt_assert(filter(el, []) = --empty--);
+
        #  eclist A (1,30,40)
        bt_assert(el = add(add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)), (rt, 10, 40)));
        bt_assert(format(el) = "(eclist (rt, 10, 1) (rt, 10, 30) (rt, 10, 40))");
@@ -950,6 +1078,13 @@ eclist r;
        bt_assert(format(r) = "(eclist (rt, 2, 1) (rt, 1, 3) (rt, 2, 2) (rt, 3, 1) (rt, 2, 3))");
        bt_assert(r.min = (rt, 1, 3));
        bt_assert(r.max = (rt, 3, 1));
+
+       # iteration over eclist
+       int x = 0;
+       for ec c in r do
+         if c > (rt, 2, 0) && c < (rt, 3, 0) then
+           x = x + 1;
+       bt_assert(x = 3);
 }
 
 bt_test_suite(t_eclist, "Testing lists of extended communities");
@@ -1034,6 +1169,9 @@ lclist r;
        ll2 = add(ll2, (30, 30, 30));
        ll2 = add(ll2, (40, 40, 40));
 
+       bt_assert(delete(ll, []) = ll);
+       bt_assert(filter(ll, []) = ---empty---);
+
        #  lclist A (10, 20, 30)
        bt_assert(format(ll) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30))");
 
@@ -1065,6 +1203,19 @@ lclist r;
        bt_assert(format(r) = "(lclist (2, 3, 3) (1, 2, 3) (2, 3, 1) (3, 1, 2) (2, 1, 3))");
        bt_assert(r.min = (1, 2, 3));
        bt_assert(r.max = (3, 1, 2));
+
+       # iteration over lclist
+       int x = 0;
+       int y = 0;
+       lc mx = (0, 0, 0);
+       for lc c in r do {
+           int asn2 = c.asn * c.asn;
+           x = x + asn2 * c.data1;
+           y = y + asn2 * c.data2;
+           if c > mx then mx = c;
+       }
+       bt_assert(x = 39 && y = 49);
+       bt_assert(mx = r.max);
 }
 
 bt_test_suite(t_lclist, "Testing lists of large communities");
@@ -1093,6 +1244,7 @@ lc set lls;
        bt_assert(ll !~ [(5,10,15), (10,21,30)]);
        bt_assert(ll !~ [(10,21..25,*)]);
        bt_assert(ll !~ [(11, *, *)]);
+       bt_assert(ll !~ []);
 
        lls = [(10, 10, 10), (20, 20, 15..25), (30, 30, *), (40, 35..45, *), (50, *, *), (55..65, *, *)];
        bt_assert(format(lls) = "[(10, 10, 10), (20, 20, 15)..(20, 20, 25), (30, 30, 0)..(30, 30, 4294967295), (40, 35, 0)..(40, 45, 4294967295), (50, 0, 0)..(50, 4294967295, 4294967295), (55, 0, 0)..(65, 4294967295, 4294967295)]");
@@ -1149,6 +1301,10 @@ bt_test_suite(t_rd, "Testing route distinguishers");
 function t_rd_set()
 rd set rds;
 {
+       rds = [];
+       bt_assert(rds = []);
+       bt_assert(10:20 !~ rds);
+
        rds = [10:20, 100000:100..100000:200];
        bt_assert(format(rds)  = "[10:20, 100000:100..100000:200]");
 
@@ -1159,6 +1315,7 @@ rd set rds;
        bt_assert(100000:128 ~ rds);
        bt_assert(100000:200 ~ rds);
        bt_assert(100010:150 !~ rds);
+       bt_assert(100010:150 !~ []);
 }
 
 bt_test_suite(t_rd_set, "Testing sets of route distinguishers");
@@ -1225,7 +1382,85 @@ function fifteen()
        return 15;
 }
 
+function local_vars(int j)
+{
+       int k = 10;
+       bt_assert(j = 5 && k = 10);
+       {
+               int j = 15;
+               k = 20;
+               bt_assert(j = 15 && k = 20);
+       }
+       bt_assert(j = 5 && k = 20);
+
+       if j < 10 then
+       {
+               int j = 25;
+               string k = "hello";
+               bt_assert(j = 25 && k = "hello");
+       }
+       bt_assert(j = 5 && k = 20);
+
+       int m = 100;
+       {
+               j = 35;
+               int k = 40;
+               bt_assert(j = 35 && k = 40 && m = 100);
+       }
+       bt_assert(j = 35 && k = 20 && m = 100);
+}
+
+function factorial(int x)
+{
+       if x = 0 then return 0;
+       if x = 1 then return 1;
+       else return x * factorial(x - 1);
+}
+
+function fibonacci(int x)
+{
+       if x = 0 then return 0;
+       if x = 1 then return 1;
+       else return fibonacci(x - 1) + fibonacci(x - 2);
+}
+
+function hanoi_init(int a; int b)
+{
+       if b = 0
+       then return +empty+;
+       else return prepend(hanoi_init(a + 1, b - 1), a);
+}
+
+function hanoi_solve(int n; bgppath h_src; bgppath h_dst; bgppath h_aux; bool x; bool y)
+{
+       # x -> return src or dst
+       # y -> print state
+
+       if n = 0 then { if x then return h_src; else return h_dst; }
+
+       bgppath tmp1 = hanoi_solve(n - 1, h_src, h_aux, h_dst, true, y);
+       bgppath tmp2 = hanoi_solve(n - 1, h_src, h_aux, h_dst, false, false);
+       h_src = tmp1;
+       h_aux = tmp2;
+
+       int v = h_src.first;
+       # bt_assert(h_dst = +empty+ || v < h_dst.first);
+       h_src = delete(h_src, v);
+       h_dst = prepend(h_dst, v);
+
+       if y then
+               print "move: ", v, " src: ", h_src, " dst:", h_dst, " aux:", h_aux;
+
+       tmp1 = hanoi_solve(n - 1, h_aux, h_dst, h_src, true, y);
+       tmp2 = hanoi_solve(n - 1, h_aux, h_dst, h_src, false, false);
+       h_aux = tmp1;
+       h_dst = tmp2;
+
+       if x then return h_src; else return h_dst;
+}
+
 function t_call_function()
+bgppath h_src;
 {
        bt_assert(fifteen() = 15);
 
@@ -1237,6 +1472,17 @@ function t_call_function()
        bt_assert(callme(4, 4) = 16);
        bt_assert(callme(7, 2) = 14);
        bt_assert(callmeagain(1, 2, 3) = 6);
+       local_vars(5);
+
+       bt_assert(factorial(5) = 120);
+       bt_assert(factorial(10) = 3628800);
+
+       bt_assert(fibonacci(10) = 55);
+       bt_assert(fibonacci(20) = 6765);
+
+       h_src = hanoi_init(1, 6);
+       bt_assert(format(h_src) = "(path 1 2 3 4 5 6)");
+       bt_assert(hanoi_solve(6, h_src, +empty+, +empty+, false, false) = h_src);
 }
 
 bt_test_suite(t_call_function, "Testing calling functions");
@@ -1433,13 +1679,16 @@ filter vpn_filter
        bt_assert(net.type != NET_IP6);
        bt_assert(net.rd = 0:1:2);
 
+       bool b = false;
        case (net.type) {
          NET_IP4: print "IPV4";
          NET_IP6: print "IPV6";
+         else: b = true;
        }
+       bt_assert(b);
 
        bt_check_assign(from, 10.20.30.40);
-       bt_check_assign(gw, 55.55.55.44);
+       bt_check_assign(gw, 55.55.55.44);
 
        bgp_community.add((3,5));
        bgp_ext_community.add((ro, 135, 999));