1
exercism fetch elixir sublist

sublist_test.exs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("sublist.exs", __DIR__)
end

ExUnit.start
ExUnit.configure exclude: :pending, trace: true

defmodule SublistTest do
  use ExUnit.Case

  test "empty equals empty" do
    assert Sublist.compare([], []) == :equal
  end

  @tag :pending
  test "empty is a sublist of anything" do
    assert Sublist.compare([], [nil]) == :sublist
  end

  @tag :pending
  test "anything is a superlist of empty" do
    assert Sublist.compare([nil], []) == :superlist
  end

  @tag :pending
  test "1 is not 2" do
    assert Sublist.compare([1], [2]) == :unequal
  end

  @tag :pending
  test "comparing massive equal lists" do
    l = Enum.to_list(1..1_000_000)
    assert Sublist.compare(l, l) == :equal
  end

  @tag :pending
  test "sublist at start" do
    assert Sublist.compare([1,2,3],[1,2,3,4,5]) == :sublist
  end

  @tag :pending
  test "sublist in middle" do
    assert Sublist.compare([4,3,2],[5,4,3,2,1]) == :sublist
  end

  @tag :pending
  test "sublist at end" do
    assert Sublist.compare([3,4,5],[1,2,3,4,5]) == :sublist
  end

  @tag :pending
  test "partially matching sublist at start" do
    assert Sublist.compare([1,1,2], [1,1,1,2]) == :sublist
  end

  @tag :pending
  test "sublist early in huge list" do
    assert Sublist.compare([3,4,5], Enum.to_list(1..1_000_000)) == :sublist
  end

  @tag :pending
  test "huge sublist not in huge list" do
    assert Sublist.compare(Enum.to_list(10..1_000_001),
                           Enum.to_list(1..1_000_000))
           == :unequal
  end

  @tag :pending
  test "superlist at start" do
    assert Sublist.compare([1,2,3,4,5],[1,2,3]) == :superlist
  end

  @tag :pending
  test "superlist in middle" do
    assert Sublist.compare([5,4,3,2,1],[4,3,2]) == :superlist
  end

  @tag :pending
  test "superlist at end" do
    assert Sublist.compare([1,2,3,4,5],[3,4,5]) == :superlist
  end

  @tag :pending
  test "1 and 2 does not contain 3" do
    assert Sublist.compare([1,2], [3]) == :unequal
  end

  @tag :pending
  test "partially matching superlist at start" do
    assert Sublist.compare([1,1,1,2], [1,1,2]) == :superlist
  end

  @tag :pending
  test "superlist early in huge list" do
    assert Sublist.compare(Enum.to_list(1..1_000_000), [3,4,5]) == :superlist
  end

  @tag :pending
  test "strict equality needed" do
    assert Sublist.compare([1], [1.0, 2]) == :unequal
  end

  @tag :pending
  test "recurring values sublist" do
    assert Sublist.compare([1,2,1,2,3], [1,2,3,1,2,1,2,3,2,1]) == :sublist
  end

  @tag :pending
  test "recurring values unequal" do
    assert Sublist.compare([1,2,1,2,3], [1,2,3,1,2,3,2,3,2,1]) == :unequal
  end
end