diff options
author | Erlang/OTP <[email protected]> | 2010-04-23 04:32:51 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-04-23 04:32:51 +0000 |
commit | c725744dc889d43a66883ac54b778fca2083a2b4 (patch) | |
tree | c5c03b58be9db2832df98797d615300a048d92d5 /lib/compiler | |
parent | 280317139a17259fd7bf1dd8bbc95bee52c053b0 (diff) | |
parent | 45c380d1b77198449fb8e3beadb39dc8f77abb72 (diff) | |
download | otp-c725744dc889d43a66883ac54b778fca2083a2b4.tar.gz otp-c725744dc889d43a66883ac54b778fca2083a2b4.tar.bz2 otp-c725744dc889d43a66883ac54b778fca2083a2b4.zip |
Merge branch 'ta/nested-records' into dev
* ta/nested-records:
Document R14 paren-less record access/update
Support nested record field access without parentheses
OTP-8597 ta/nested-records
Nested records can now be accessed without parenthesis. See the Reference
Manual for examples. (Thanks to YAMASHINA Hio and Tuncer Ayaz.)
Diffstat (limited to 'lib/compiler')
-rw-r--r-- | lib/compiler/test/record_SUITE.erl | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/compiler/test/record_SUITE.erl b/lib/compiler/test/record_SUITE.erl index bd2ffd7f65..f26ff769c7 100644 --- a/lib/compiler/test/record_SUITE.erl +++ b/lib/compiler/test/record_SUITE.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2003-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2003-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %%% Purpose : Test records. @@ -24,7 +24,7 @@ -export([all/1,init_per_testcase/2,fin_per_testcase/2, errors/1,record_test_2/1,record_test_3/1,record_access_in_guards/1, - guard_opt/1,eval_once/1,foobar/1,missing_test_heap/1]). + guard_opt/1,eval_once/1,foobar/1,missing_test_heap/1, nested_access/1]). init_per_testcase(_Case, Config) -> ?line Dog = test_server:timetrap(test_server:minutes(2)), @@ -38,7 +38,7 @@ fin_per_testcase(_Case, Config) -> all(suite) -> test_lib:recompile(?MODULE), [errors,record_test_2,record_test_3,record_access_in_guards, - guard_opt,eval_once,foobar,missing_test_heap]. + guard_opt,eval_once,foobar,missing_test_heap,nested_access]. -record(foo, {a,b,c,d}). -record(bar, {a,b,c,d}). @@ -522,4 +522,29 @@ missing_test_heap_1(A = #foo_rec {foo_1 = _B, foo_3 = C + 1, foo_2 = D + 1}. +-record(nrec0, {name = <<"nested0">>}). +-record(nrec1, {name = <<"nested1">>, nrec0=#nrec0{}}). +-record(nrec2, {name = <<"nested2">>, nrec1=#nrec1{}}). + +nested_access(Config) when is_list(Config) -> + N0 = #nrec0{}, + N1 = #nrec1{}, + N2 = #nrec2{}, + ?line <<"nested0">> = N0#nrec0.name, + ?line <<"nested1">> = N1#nrec1.name, + ?line <<"nested2">> = N2#nrec2.name, + ?line <<"nested0">> = N1#nrec1.nrec0#nrec0.name, + ?line <<"nested0">> = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name, + ?line <<"nested1">> = N2#nrec2.nrec1#nrec1.name, + ?line <<"nested0">> = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name, + + N1a = N2#nrec2.nrec1#nrec1{name = <<"nested1a">>}, + ?line <<"nested1a">> = N1a#nrec1.name, + + N2a = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = <<"nested0a">>}, + N2b = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = <<"nested0a">>}, + ?line <<"nested0a">> = N2a#nrec0.name, + ?line N2a = N2b, + ok. + id(I) -> I. |