From 6bf5c3e8fd986fd4ef6d3fcebc8a62bd15870e21 Mon Sep 17 00:00:00 2001 From: Angelika Cathor Date: Sat, 23 Aug 2025 10:10:31 +0200 Subject: [PATCH] Refactor dot-dsl tests --- exercises/practice/dot-dsl/test/dot_test.exs | 77 ++++++++++++++------ 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/exercises/practice/dot-dsl/test/dot_test.exs b/exercises/practice/dot-dsl/test/dot_test.exs index ef65c5caa9..8e6f387cf4 100644 --- a/exercises/practice/dot-dsl/test/dot_test.exs +++ b/exercises/practice/dot-dsl/test/dot_test.exs @@ -57,7 +57,7 @@ defmodule DotTest do end @tag :pending - test "graph with just attribute" do + test "graph with one attribute" do assert %Graph{attrs: %{foo: 1}} == exprt( Dot.graph do @@ -67,7 +67,7 @@ defmodule DotTest do end @tag :pending - test "graph with attrs" do + test "graph with many attributes, nodes, and edges" do assert %Graph{ attrs: %{bar: true, foo: 1, title: "Testing Attrs"}, nodes: %{a: %{color: :green}, b: %{label: "Beta!"}, c: %{}}, @@ -89,107 +89,107 @@ defmodule DotTest do end @tag :pending - test "keywords stuck to graph without space" do + test "invalid graph attribute syntax: wrong argument type" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - graph[[title: "Bad"]] + graph("Bad") end ) end end @tag :pending - test "keywords stuck to node without space" do + test "invalid graph attribute syntax: not a call" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - a[[label: "Alpha!"]] + graph[title: "Bad"] end ) end end @tag :pending - test "keywords stuck to edge without space" do + test "invalid node syntax: numerical node name" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - a -- b[[label: "Bad"]] + a + 2 end ) end end @tag :pending - test "invalid statement: int" do + test "invalid node syntax: wrong argument type" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - a - 2 + a("Alpha!") end ) end end @tag :pending - test "invalid statement: list" do + test "invalid node syntax: not a call" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - [title: "Testing invalid"] + a[label: "Alpha!"] end ) end end @tag :pending - test "invalid statement: qualified atom" do + test "invalid node syntax: two attribute lists" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - Enum.map() + a([color: green], label: "Alpha!") end ) end end @tag :pending - test "invalid statement: graph with no keywords" do + test "invalid node syntax: non-keyword attribute list" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - Enum.map() + a(["Alpha!", color: green]) end ) end end @tag :pending - test "two attribute lists" do + test "invalid edge syntax: wrong argument type" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - a([color: green][[label: "Alpha!"]]) + a -- b("Bad") end ) end end @tag :pending - test "non-keyword attribute list" do + test "invalid edge syntax: not a call" do assert_raise ArgumentError, fn -> exprt( Dot.graph do - a(["Alpha!", color: green]) + a -- b[label: "Bad"] end ) end end @tag :pending - test "int edge" do + test "invalid edge syntax: numerical node names" do assert_raise ArgumentError, fn -> exprt( Dot.graph do @@ -206,4 +206,37 @@ defmodule DotTest do ) end end + + @tag :pending + test "invalid statement: keyword list" do + assert_raise ArgumentError, fn -> + exprt( + Dot.graph do + [title: "Testing invalid"] + end + ) + end + end + + @tag :pending + test "invalid statement: qualified atom" do + assert_raise ArgumentError, fn -> + exprt( + Dot.graph do + Enum.map() + end + ) + end + end + + @tag :pending + test "invalid statement: graph with no keywords" do + assert_raise ArgumentError, fn -> + exprt( + Dot.graph do + graph() + end + ) + end + end end