diff options
author | José Valim <[email protected]> | 2012-03-23 14:53:15 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2012-04-10 12:32:23 +0200 |
commit | 2d785c07fbf9f533bf4627a65315a51c3efc2113 (patch) | |
tree | 852ae25edd463ba52745c315372776af1fda4a2f /lib/compiler/test | |
parent | 5573888eea1ff6e3e169a6c873c2f5ada81eab62 (diff) | |
download | otp-2d785c07fbf9f533bf4627a65315a51c3efc2113.tar.gz otp-2d785c07fbf9f533bf4627a65315a51c3efc2113.tar.bz2 otp-2d785c07fbf9f533bf4627a65315a51c3efc2113.zip |
Allow the source to be set when compiling forms
This commit adds a source option to compile:forms() that
sets the source value returned by module_info(compile).
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/compile_SUITE.erl | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl index 512fa0e4ac..0dfa18490a 100644 --- a/lib/compiler/test/compile_SUITE.erl +++ b/lib/compiler/test/compile_SUITE.erl @@ -25,7 +25,7 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, app_test/1, - file_1/1, module_mismatch/1, big_file/1, outdir/1, + file_1/1, forms_2/1, module_mismatch/1, big_file/1, outdir/1, binary/1, makedep/1, cond_and_ifdef/1, listings/1, listings_big/1, other_output/1, package_forms/1, encrypted_abstr/1, bad_record_use1/1, bad_record_use2/1, strict_record/1, @@ -42,7 +42,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> test_lib:recompile(?MODULE), - [app_test, file_1, module_mismatch, big_file, outdir, + [app_test, file_1, forms_2, module_mismatch, big_file, outdir, binary, makedep, cond_and_ifdef, listings, listings_big, other_output, package_forms, encrypted_abstr, {group, bad_record_use}, strict_record, @@ -105,6 +105,21 @@ file_1(Config) when is_list(Config) -> ?line test_server:timetrap_cancel(Dog), ok. +forms_2(Config) when is_list(Config) -> + {ok, simple, Binary} = compile:forms([{attribute,1,module,simple}], [binary, {source,"/foo/bar"}]), + code:load_binary(simple, "/foo/bar", Binary), + Info = simple:module_info(compile), + + %% Test proper source is returned. + "/foo/bar" = proplists:get_value(source, Info), + %% Ensure options is not polluted with the source. + [] = proplists:get_value(options, Info), + + %% Cleanup. + true = code:delete(simple), + false = code:purge(simple), + ok. + module_mismatch(Config) when is_list(Config) -> ?line DataDir = ?config(data_dir, Config), ?line File = filename:join(DataDir, "wrong_module_name.erl"), |