2 Documentation Unit test suite to ScalarClosures library.
4 ... Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
11 ... TODO: Improve test converage.
13 Resource ${CURDIR}/../../../libraries/ScalarClosures.robot
16 Identity_Closure_Defined
17 [Documentation] An identity closure is created, comparison shows it is equal to a variable set in library setup.
18 ${actual} = BuiltIn.Set_Variable ${ScalarClosures__identity}
19 ${expected} = ScalarClosures.Closure_From_Keyword_And_Arguments BuiltIn.Set_Variable placeholder
20 BuiltIn.Should_Be_Equal ${actual} ${expected}
22 Zero_Args_No_Kwargs_Execution_Test
23 [Documentation] The identity closure is run as is, the placeholder is visible.
24 ${actual} = ScalarClosures.Run_Closure_As_Is ${ScalarClosures__identity}
25 BuiltIn.Should_Be_Equal ${actual} placeholder
27 One_Arg_No_Kwargs_Execution_Test
28 [Documentation] The identity closure is run with rerplaced argument, the value is visible.
29 ${actual} = ScalarClosures.Run_Closure_After_Replacing_First_Argument ${ScalarClosures__identity} first_value
30 BuiltIn.Should_Be_Equal ${actual} first_value
32 Two_Args_No_Kwargs_Execution_Test
33 [Documentation] Closure which puts two placeholders into list is created, run with substitution shows new values in list.
34 ${closure} = ScalarClosures.Closure_From_Keyword_And_Arguments BuiltIn.Set_Variable first_placeholder second_placeholder
35 ${actual} = ScalarClosures.Run_Closure_After_Replacing_First_Two_Arguments ${closure} first_value second_value
36 ${expected} = BuiltIn.Set_Variable first_value second_value
37 BuiltIn.Should_Be_Equal ${actual} ${expected}
39 One_Kwarg_Nested_In_Zero_Args_Execution_Test
40 [Documentation] Inner closure takes kwarg, outer closure runs it as is. Result shows execution chain went well and kwarg was processed.
41 ${inner_closure} = ScalarClosures.Closure_From_Keyword_And_Arguments BuiltIn.Create_Dictionary foo=bar
42 # As stated in Documentation of ScalarClosures in Current limitation,
43 # BuiltIn.Create_Directory will get empty list in @{args}, which will trigger deprecation warning.
44 # TODO: Investigate whether it is a genuine bug in Robot.
45 ${outer_closure} = ScalarClosures.Closure_From_Keyword_And_Arguments ScalarClosures.Run_Closure_As_Is ${inner_closure}
46 ${actual} = ScalarClosures.Run_Closure_As_Is ${outer_closure}
47 ${expected} = BuiltIn.Create_Dictionary foo=bar
48 BuiltIn.Should_Be_Equal ${actual} ${expected}
52 [Documentation] Call ScalarClosures setup.
53 ScalarClosures.SC_Setup