vtest "VCL compiler coverage test: vcc_xref.c vcc_var.c vcc_symb.c"

vinyl v1 -errvcl {Variable is read only.} {
	backend b { .host = "${localhost}"; }
	sub vcl_deliver { set obj.ttl = 1 w; }
}

vinyl v1 -errvcl {Variable is read only.} {
	backend b { .host = "${localhost}"; }

	sub foo { set obj.ttl = 1 w; }
	sub vcl_deliver { call foo; }
}

vinyl v1 -errvcl {Not available in subroutine 'vcl_recv'.} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { set obj.ttl = 1 w; }
}

vinyl v1 -errvcl {Not available from subroutine 'vcl_recv'.} {
	backend b { .host = "${localhost}"; }

	sub foo { set obj.ttl = 1 w; }
	sub vcl_recv { call foo; }
}

vinyl v1 -errvcl "Symbol not found" {
	backend b { .host = "${localhost}"; }

	sub vcl_recv { discard; }
}

vinyl v1 -errvcl "Symbol not found" {
	backend b { .host = "${localhost}"; }

	sub foo { discard; }
	sub vcl_recv { call foo; }
}

vinyl v1 -errvcl {
Subroutine recurses on
('<vcl.inline>' Line 5 Pos 13)
        sub foo { call foo; }
------------###--------------


...called from "foo"
('<vcl.inline>' Line 5 Pos 24)
        sub foo { call foo; }
-----------------------###---

} {
	backend b { .host = "${localhost}"; }

	sub foo { call foo; }
	sub vcl_recv { call foo; }
}

vinyl v1 -errvcl {
('<vcl.inline>' Line 5 Pos 13)
        sub bar { call foo; }
------------###--------------


...called from "foo"
('<vcl.inline>' Line 6 Pos 24)
        sub foo { call bar; }
-----------------------###---


...called from "bar"
('<vcl.inline>' Line 5 Pos 24)
        sub bar { call foo; }
-----------------------###---

} {
	backend b { .host = "${localhost}"; }

	sub bar { call foo; }
	sub foo { call bar; }
	sub vcl_recv { call foo; }
}

vinyl v1 -errvcl {Unused acl foo, defined:} {
	backend b { .host = "${localhost}"; }

	acl foo { "${localhost}"; }

}

vinyl v1 -errvcl {Unused sub foo, defined:} {
	backend b { .host = "${localhost}"; }

	sub foo {
	}
}

# deliberately testing for name "none"
vinyl v1 -errvcl {Unused sub none, defined:} {
	backend b { .host = "${localhost}"; }

	sub none {
	}
}

vinyl v1 -errvcl {Invalid return "deliver"} {
	backend b { .host = "${localhost}"; }

	sub vcl_recv {
		call foo;
	}

	sub foo {
		return (deliver);
	}
}

vinyl v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} {

	backend foo { .host = "${localhost}"; }

	sub vcl_deliver {
		set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambucking = "foobar";
	}
}

vinyl v1 -vcl {

	backend foo { .host = "${localhost}"; }

	sub vcl_deliver {
		set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckin = "foobar";
	}
}

vinyl v1 -errvcl {Symbol not found: 'req.foobar'} {
	backend foo { .host = "${localhost}"; }
	sub vcl_recv { set req.foobar = 3; }
}

vinyl v1 -errvcl {Symbol 'anacl' has wrong type (acl), expected sub:} {
	sub vcl_recv {
		if (client.ip ~ anacl) { }
	}
	sub anacl { }
}

vinyl v1 -errvcl {Symbols named 'vcl_*' are reserved.} {
	sub vcl_recv {
		if (client.ip ~ vcl_foo) { }
	}
}

# 3628
vinyl v1 -vcl {
	backend be none;
	acl foo { }
	sub vcl_recv {
		if (client.ip ~ foo || server.ip ~ foo) { }
	}
}

vinyl v1 -errvcl {Expression has type BOOL, expected ACL} {
	sub vcl_recv {
		if (client.ip ~ true) { }
	}
}

vinyl v1 -errvcl {Symbol 'default' is a reserved word.} {
	sub vcl_recv {
		if (client.ip ~ default) { }
	}
}

vinyl v1 -syntax 4.1 -errvcl {(Only available when VCL syntax <= 4.0)} {
	sub vcl_recv {
		set req.esi = false;
	}
}
vinyl v1 -syntax 4.0 -errvcl {(Only available when 4.1 <= VCL syntax)} {
	sub vcl_deliver {
		set resp.do_esi = false;
	}
}
