|
| 1 | +defmodule ElixirAnalyzer.TestSuite.GottaSnatchEmAll do |
| 2 | + @moduledoc """ |
| 3 | + This is an exercise analyzer extension module for the concept exercise Gotta Snatch Em All |
| 4 | + """ |
| 5 | + use ElixirAnalyzer.ExerciseTest |
| 6 | + alias ElixirAnalyzer.Constants |
| 7 | + |
| 8 | + assert_call "add_card uses MapSet.member?" do |
| 9 | + type :essential |
| 10 | + calling_fn module: GottaSnatchEmAll, name: :add_card |
| 11 | + called_fn module: MapSet, name: :member? |
| 12 | + comment Constants.gotta_snatch_em_all_add_card_use_mapset_member_and_put() |
| 13 | + end |
| 14 | + |
| 15 | + assert_call "add_card uses MapSet.put" do |
| 16 | + type :essential |
| 17 | + calling_fn module: GottaSnatchEmAll, name: :add_card |
| 18 | + called_fn module: MapSet, name: :put |
| 19 | + comment Constants.gotta_snatch_em_all_add_card_use_mapset_member_and_put() |
| 20 | + suppress_if "add_card uses MapSet.member?", :fail |
| 21 | + end |
| 22 | + |
| 23 | + assert_call "trade_card uses MapSet.member?" do |
| 24 | + type :essential |
| 25 | + calling_fn module: GottaSnatchEmAll, name: :trade_card |
| 26 | + called_fn module: MapSet, name: :member? |
| 27 | + comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete() |
| 28 | + end |
| 29 | + |
| 30 | + assert_call "trade_card uses MapSet.put" do |
| 31 | + type :essential |
| 32 | + calling_fn module: GottaSnatchEmAll, name: :trade_card |
| 33 | + called_fn module: MapSet, name: :put |
| 34 | + comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete() |
| 35 | + suppress_if "trade_card uses MapSet.member?", :fail |
| 36 | + end |
| 37 | + |
| 38 | + assert_call "trade_card uses MapSet.delete" do |
| 39 | + type :essential |
| 40 | + calling_fn module: GottaSnatchEmAll, name: :trade_card |
| 41 | + called_fn module: MapSet, name: :delete |
| 42 | + comment Constants.gotta_snatch_em_all_trade_card_use_mapset_member_put_and_delete() |
| 43 | + suppress_if "trade_card uses MapSet.member?", :fail |
| 44 | + suppress_if "trade_card uses MapSet.put", :fail |
| 45 | + end |
| 46 | + |
| 47 | + assert_call "remove_duplicates uses MapSet.new" do |
| 48 | + type :essential |
| 49 | + calling_fn module: GottaSnatchEmAll, name: :remove_duplicates |
| 50 | + called_fn module: MapSet, name: :new |
| 51 | + comment Constants.gotta_snatch_em_all_remove_duplicates_use_mapset_new() |
| 52 | + end |
| 53 | + |
| 54 | + assert_call "remove_duplicates uses Enum.sort" do |
| 55 | + type :essential |
| 56 | + calling_fn module: GottaSnatchEmAll, name: :remove_duplicates |
| 57 | + called_fn module: Enum, name: :sort |
| 58 | + comment Constants.gotta_snatch_em_all_remove_duplicates_use_enum_sort() |
| 59 | + end |
| 60 | + |
| 61 | + assert_no_call "remove_duplicates does not use Enum.uniq" do |
| 62 | + type :essential |
| 63 | + calling_fn module: GottaSnatchEmAll, name: :remove_duplicates |
| 64 | + called_fn module: Enum, name: :uniq |
| 65 | + comment Constants.gotta_snatch_em_all_remove_duplicates_do_not_use_enum_uniq() |
| 66 | + end |
| 67 | + |
| 68 | + assert_call "extra_cards uses MapSet.difference" do |
| 69 | + type :essential |
| 70 | + calling_fn module: GottaSnatchEmAll, name: :extra_cards |
| 71 | + called_fn module: MapSet, name: :difference |
| 72 | + comment Constants.gotta_snatch_em_all_extra_cards_use_mapset_difference_and_size() |
| 73 | + end |
| 74 | + |
| 75 | + assert_call "extra_cards uses MapSet.size" do |
| 76 | + type :essential |
| 77 | + calling_fn module: GottaSnatchEmAll, name: :extra_cards |
| 78 | + called_fn module: MapSet, name: :size |
| 79 | + comment Constants.gotta_snatch_em_all_extra_cards_use_mapset_difference_and_size() |
| 80 | + suppress_if "extra_cards uses MapSet.difference", :fail |
| 81 | + end |
| 82 | + |
| 83 | + assert_call "boring_cards uses MapSet.intersection" do |
| 84 | + type :essential |
| 85 | + calling_fn module: GottaSnatchEmAll, name: :boring_cards |
| 86 | + called_fn module: MapSet, name: :intersection |
| 87 | + comment Constants.gotta_snatch_em_all_boring_cards_use_mapset_intersection() |
| 88 | + end |
| 89 | + |
| 90 | + assert_call "boring_cards uses Enum.sort" do |
| 91 | + type :essential |
| 92 | + calling_fn module: GottaSnatchEmAll, name: :boring_cards |
| 93 | + called_fn module: Enum, name: :sort |
| 94 | + comment Constants.gotta_snatch_em_all_boring_cards_use_enum_sort() |
| 95 | + end |
| 96 | + |
| 97 | + assert_call "boring_cards uses Enum.reduce" do |
| 98 | + type :actionable |
| 99 | + calling_fn module: GottaSnatchEmAll, name: :boring_cards |
| 100 | + called_fn module: Enum, name: :reduce |
| 101 | + comment Constants.gotta_snatch_em_all_boring_cards_use_enum_reduce() |
| 102 | + end |
| 103 | + |
| 104 | + assert_call "total_cards uses MapSet.union" do |
| 105 | + type :essential |
| 106 | + calling_fn module: GottaSnatchEmAll, name: :total_cards |
| 107 | + called_fn module: MapSet, name: :union |
| 108 | + comment Constants.gotta_snatch_em_all_total_cards_use_mapset_union_and_size() |
| 109 | + end |
| 110 | + |
| 111 | + assert_call "total_cards uses MapSet.size" do |
| 112 | + type :essential |
| 113 | + calling_fn module: GottaSnatchEmAll, name: :total_cards |
| 114 | + called_fn module: MapSet, name: :size |
| 115 | + comment Constants.gotta_snatch_em_all_total_cards_use_mapset_union_and_size() |
| 116 | + suppress_if "total_cards uses MapSet.union", :fail |
| 117 | + end |
| 118 | + |
| 119 | + assert_call "total_cards uses Enum.reduce" do |
| 120 | + type :actionable |
| 121 | + calling_fn module: GottaSnatchEmAll, name: :total_cards |
| 122 | + called_fn module: Enum, name: :reduce |
| 123 | + comment Constants.gotta_snatch_em_all_total_cards_use_enum_reduce() |
| 124 | + end |
| 125 | + |
| 126 | + assert_call "split_shiny_cards uses Enum.sort" do |
| 127 | + type :essential |
| 128 | + calling_fn module: GottaSnatchEmAll, name: :split_shiny_cards |
| 129 | + called_fn module: Enum, name: :sort |
| 130 | + comment Constants.gotta_snatch_em_all_split_shiny_cards_use_enum_sort() |
| 131 | + end |
| 132 | + |
| 133 | + assert_call "split_shiny_cards uses String.starts_with" do |
| 134 | + type :actionable |
| 135 | + calling_fn module: GottaSnatchEmAll, name: :split_shiny_cards |
| 136 | + called_fn module: String, name: :starts_with? |
| 137 | + comment Constants.gotta_snatch_em_all_split_shiny_cards_use_string_starts_with() |
| 138 | + end |
| 139 | +end |
0 commit comments