   alias TheOneTrueJSON, as: JSON
 
   # just for reference mainly
-  @contexts { :string, :number, :decimal, :exponent, :array, :object, :pair, :key, :value, :boolean }
+  @contexts { :string, :number, :decimal, :exponent, :array, :object, :pair, :key, :value, :boolean, :comma_or_close_array, :comma_or_close_object }
   @whitespace '\s\n\t\r'
   @number_start '-0123456789'
   @digits ?0..?9

  end

  @doc """
  Closing arrays, when a value is not expected. If it matches, pop that context.
  """
  def parse(<<?], t::binary>>, [:array | context], output) do

    test "object with wrong string key delimiter" do
      assert {:error, _} = JSON.parse("{'65': 23}")
    end
    test "consecutive booleans in array, no comma" do
      assert {:error, _} = JSON.parse("[true false]")
    end
    test "comma at start of array" do
      assert {:error, _} = JSON.parse("[,true]")
    end
    test "comma at end of array" do
      assert {:error, _} = JSON.parse("[false,]")
    end
    test "comma at start of object" do
      assert {:error, _} = JSON.parse("{,\"b\":true}")
    end
    test "comma at end of object" do
      assert {:error, _} = JSON.parse("{\"a\":false,}")
    end

  end
end
