THRIFT-3214 Add Erlang option for using maps instead of dicts
Client: Erlang
Patch: Michael Oliver <mikemboliver@gmail.com>

This closes #535
diff --git a/lib/erl/Makefile.am b/lib/erl/Makefile.am
index 60c7e5a..1f65a24 100644
--- a/lib/erl/Makefile.am
+++ b/lib/erl/Makefile.am
@@ -25,6 +25,7 @@
 	for f in $(THRIFT_FILES) ; do \
 	  $(THRIFT) --gen erl -o test $$f ; \
 	done ; \
+	$(THRIFT) --gen erl:maps -o test test/Thrift3214.thrift ; \
 	touch .generated
 
 all: .generated
diff --git a/lib/erl/test/Thrift3214.thrift b/lib/erl/test/Thrift3214.thrift
new file mode 100644
index 0000000..a9110ce
--- /dev/null
+++ b/lib/erl/test/Thrift3214.thrift
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+struct StringMap
+{
+  1: map<i32, string> data = {1: "a", 2: "b"};
+}
diff --git a/lib/erl/test/test_thrift_3214.erl b/lib/erl/test/test_thrift_3214.erl
new file mode 100644
index 0000000..118e779
--- /dev/null
+++ b/lib/erl/test/test_thrift_3214.erl
@@ -0,0 +1,58 @@
+%%
+%% Licensed to the Apache Software Foundation (ASF) under one
+%% or more contributor license agreements. See the NOTICE file
+%% distributed with this work for additional information
+%% regarding copyright ownership. The ASF licenses this file
+%% to you under the Apache License, Version 2.0 (the
+%% "License"); you may not use this file except in compliance
+%% with the License. You may obtain a copy of the License at
+%%
+%%   http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing,
+%% software distributed under the License is distributed on an
+%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%% KIND, either express or implied. See the License for the
+%% specific language governing permissions and limitations
+%% under the License.
+%%
+
+-module(test_thrift_3214).
+-compile(export_all).
+
+-include("gen-erl/thrift3214_types.hrl").
+
+-ifdef(TEST).
+-include_lib("eunit/include/eunit.hrl").
+
+record_generation_test_() ->
+  [
+    {"StringMap record", ?_assertMatch(
+      {'StringMap', _},
+      #'StringMap'{data=#{50 => "foo"}}
+    )},
+    {"StringMap record defaults", ?_assertEqual(
+      {'StringMap', #{1 => "a", 2 => "b"}},
+      #'StringMap'{}
+    )},
+    {"StringMap record dict from list", ?_assertNotEqual(
+      {'StringMap', dict:from_list([{1, "a"}, {2, "b"}])},
+      #'StringMap'{}
+    )},
+    {"StringMap record map from list", ?_assertEqual(
+      {'StringMap', maps:from_list([{1, "a"}, {2, "b"}])},
+      #'StringMap'{}
+    )}
+  ].
+
+struct_info_test_() ->
+  [
+    {"StringMap extended definition", ?_assertEqual(
+      {struct, [
+        {1, undefined, {map, i32, string}, 'data', #{1 => "a", 2 => "b"}}
+      ]},
+      thrift3214_types:struct_info_ext('StringMap')
+    )}
+  ].
+
+-endif.