              quote do: (case w() do x -> x = x; y -> y = y end; :erlang.+(x, y))
     end
 
-    test "expects at most one do" do
+    test "expects exactly one do" do
+      assert_raise CompileError, ~r"missing do keyword in case", fn ->
+        expand(quote(do: (case e, [])))
+      end
+
       assert_raise CompileError, ~r"duplicated do clauses given for case", fn ->
         expand(quote(do: (case e, do: (x -> x), do: (y -> y))))
+      end
+    end
+
+    test "expects clauses" do
+      assert_raise CompileError, ~r"expected -> clauses for do in case", fn ->
+        expand(quote do: (case e do x end))
+      end
+    end
+
+    test "expects exactly one argument in clauses" do
+      assert_raise CompileError, ~r"expected one arg for do clauses \(->\) in case", fn ->
+        expand(quote do: (case e do _, _ -> :ok end))
+      end
+    end
+
+    test "fails with invalid arguments" do
+      assert_raise CompileError, ~r"invalid arguments for case", fn ->
+        expand(quote do: (case :foo, :bar))
+      end
+    end
+
+    test "fails for invalid keywords" do
+      assert_raise CompileError, ~r"unexpected keyword foo in case", fn ->
+        expand(quote do: (case e, do: (x -> x), foo: :bar))
       end
     end
   end

             quote do: (receive do x -> x = x after y() -> y(); w = y() end; :erlang.+(x, w))
    end

    test "expects at most one clause" do
      assert_raise CompileError, ~r"duplicated do clauses given for receive", fn ->
        expand(quote(do: (receive do: (x -> x), do: (y -> y))))
      end

      assert_raise CompileError, ~r"duplicated after clauses given for receive", fn ->
        expand(quote(do: (receive do x -> x after y -> y after z -> z end)))
      end
    end
  end

             quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))
    end

    test "expects exactly one do" do
      assert_raise CompileError, ~r"missing do keyword in cond", fn ->
        expand(quote do: (cond []))
      end

      assert_raise CompileError, ~r"duplicated do clauses given for cond", fn ->
        expand(quote(do: (cond do: (x -> x), do: (y -> y))))
      end
    end

    test "expects one argument in clauses" do
      assert_raise CompileError, ~r"expected one arg for do clauses \(->\) in cond", fn ->
        expand(quote do: (cond do _, _ -> :ok end))
      end
    end

    test "raises for invalid arguments" do
      assert_raise CompileError, ~r"invalid arguments for cond", fn ->
        expand(quote do: (cond :foo))
      end
    end

    test "raises with invalid keywords" do
      assert_raise CompileError, ~r"unexpected keyword foo in cond", fn ->
        expand(quote do: (cond do: (1 -> 1), foo: :bar))
      end
    end

