     assert render(group(doc), 5) == "hello\na\nb\ncd"
   end
 
-  test "groups with lines" do
+  test "collapse lines" do
+    # Consistent with definitions
+    assert collapse_lines(3) == {:doc_collapse, 3}
+
+    # Wrong argument type
+    assert_raise FunctionClauseError, fn -> collapse_lines(0) end
+    assert_raise FunctionClauseError, fn -> collapse_lines(empty()) end
+
+    # Consistent formatting
+    doc = concat([collapse_lines(2), line(), line(), line()])
+    assert render(doc, 10) == "\n\n"
+    assert render(nest(doc, 2), 10) == "\n\n  "
+
+    doc = concat([collapse_lines(2), line(), line()])
+    assert render(doc, 10) == "\n\n"
+    assert render(nest(doc, 2), 10) == "\n\n  "
+
+    doc = concat([collapse_lines(2), line()])
+    assert render(doc, 10) == "\n"
+    assert render(nest(doc, 2), 10) == "\n  "
+
+    doc = concat([collapse_lines(2), line(), "", line(), "", line()])
+    assert render(doc, 10) == "\n\n"
+    assert render(nest(doc, 2), 10) == "\n\n  "
+
+    doc = concat([collapse_lines(2), line(), "foo", line(), "bar", line()])
+    assert render(doc, 10) == "\nfoo\nbar\n"
+    assert render(nest(doc, 2), 10) == "\n  foo\n  bar\n  "
+  end
+
+  test "force doc and cancel doc" do
+    # Consistent with definitions
+    assert force_break("ab") == {:doc_force, "ab"}
+    assert force_break(empty()) == {:doc_force, empty()}
+
+    # Consistent with definitions
+    assert cancel_break("ab") == {:doc_cancel, "ab", :enabled}
+    assert cancel_break(empty()) == {:doc_cancel, empty(), :enabled}
+    assert cancel_break("ab", :disabled) == {:doc_cancel, "ab", :disabled}
+    assert cancel_break(empty(), :disabled) == {:doc_cancel, empty(), :disabled}
+
+    # Consistent formatting
+    doc = force_break(concat(glue(glue(glue("hello", "a"), "b"), "c"), "d"))
+    assert render(doc, 20) == "hello\na\nb\ncd"
+    assert render(cancel_break(doc, :enabled), 20) == "hello a b cd"
+    assert render(cancel_break(cancel_break(doc, :enabled), :disabled), 20) == "hello\na\nb\ncd"
+  end
+
+  test "formatting groups with lines" do
     doc = line(glue("a", "b"), glue("hello", "world"))
     assert render(group(doc), 5) == "a\nb\nhello\nworld"
     assert render(group(doc), 100) == "a b\nhello world"

    # Consistent formatting
    assert render(nest("a", 1), 80) == "a"
    assert render(nest(glue("a", "b"), 1), 2) == "a\n b"
  end

  test "color doc" do

  test "formatting with infinity" do
    s = String.duplicate "x", 50
    g = ";"
    doc = glue(s, g, s) |> glue(g, s) |> glue(g, s) |> glue(g, s) |> group

    assert render(doc, :infinity) == s <> g <> s <> g <> s <> g <> s <> g <> s
  end
