vtest "VCL compiler coverage test: vcc_action.c"

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_miss { return(synth(100,req.url)); }
	sub vcl_hit { return(synth(100,"the butter please")); }
	sub vcl_deliver { return(synth(resp.status, resp.reason)); }
}

vinyl v1 -errvcl {Variable is read only.} {
	backend b { .host = "${localhost}"; }
	sub vcl_miss { set now += 1s; }
}

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.ttl /= 2; }
}

vinyl v1 -errvcl {Expected '=' got '>>'} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.ttl >>= 2; }
}

vinyl v1 -errvcl {Expected '=' got '+='} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_fetch { set bereq.backend += b; }
}

vinyl v1 -errvcl {Expected ';' got 'if'} {
	backend b { .host = "${localhost}"; }
	/* XXX: This should not really be an synth */
	sub vcl_recv { set req.url = "foo" if "bar"; }
}

vinyl v1 -errvcl {Unknown property 'foo' for type HTTP} {
	backend b { .host = "${localhost}"; }
	sub vcl_hash { hash_data(req.foo); }
}

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { set req.url = 1; }
}

vinyl v1 -errvcl {Expected '=' got '+='} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.do_gzip += 1; }
}

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.do_gzip = true; }
}

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.do_gzip = false; }
}

vinyl v1 -errvcl {Symbol not found: 'mu'} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { set beresp.do_gzip = mu; }
}

vinyl v1 -errvcl {Variable cannot be unset} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_response { unset beresp.do_gzip; }
}

vinyl v1 -errvcl {Variable cannot be set.} {
	backend b { .host = "${localhost}"; }
	sub vcl_backend_fetch { set bereq.body = "foo"; }
}

vinyl v1 -errvcl {Unknown token '<<' when looking for STRING} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { ban (<<); }
}

vinyl v1 -errvcl {Symbol not found} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { ban_hash (if); }
}

vinyl v1 -vcl {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { ban ("req.url ~ foo"); }
}

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

vinyl v1 -errvcl {Unknown token '<<' when looking for STRING} {
	backend b { .host = "${localhost}"; }
	sub vcl_synth { synthetic( << "foo"; }
}

vinyl v1 -errvcl {Missing argument.} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { return(synth); }
}

vinyl v1 -errvcl {Arguments not allowed.} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { return(pipe(XXX); }
}

vinyl v1 -errvcl {Expected return action name.} {
	backend b { .host = "${localhost}"; }
	sub vcl_recv { return(foobar); }
}

# issue #936
vinyl v1 -errvcl {Not a valid action in subroutine 'vcl_recv'} {
	backend foo { .host = "${localhost}"; }
	sub vcl_recv {
		synthetic("XXX");
		return (synth(503));
	}
}

vinyl v1 -errvcl {Symbol 'vcl_recv' has wrong type (sub), expected vcl:} {
	sub vcl_recv {
		return (vcl(vcl_recv));
	}
}

vinyl v1 -syntax 4.0 -errvcl {Symbol not found:} {
	sub vcl_recv {
		return (vcl(vcl_recv));
	}
}

vinyl v1 -errvcl {Syntax error} {
	import directors;
	sub vcl_recv {
		set req.backend_hint = directors.round_robin.backend();
	}
}

vinyl v1 -errvcl {Syntax error} {
	import directors;
	sub vcl_recv {
		directors.round_robin.backend();
	}
}

vinyl v1 -errvcl {Expected '.' got ';'} {
	import directors;
	sub vcl_init {
		new rr = directors.round_robin();
		rr;
	}
}

vinyl v1 -vcl {
	backend default none;

	import debug;

	sub vcl_recv {
		return (fail(debug.author()));
	}
}
