Skip to content

Usage of Filter Each Function with value variable named "value" variable causes invalid test results #134

@Dickelcsl

Description

@Dickelcsl

I think I have discovered a bug using the variable name "value" in a function to be tested and containing a "Filter Each" function.
To prove this I have written the below simple function which gets a list as parameter. The function will return "1" if it contains only strings. Additionally the functions filters also missing values from the list before checking each value.

test1 = function( {input},{default local}, input = Filter Each({x}, input, !(IsMissing(x)==1)); if(input == Filter Each({value},input, Is String(value)==1), return (1), // Exit if filtered list contains only strings return (0)); // Exit if filtered list contains other items );

If I call the function it works as expected:

Show(test1({"a","b",.})); // => 1 Contains only strings Show(test1({1,2})); // => 0 Contains numbers only Show(test1({1,"a",2,"b"})); // => 0 Contains numbers and strings

Now I am writing my test function:

Test1 test case = ut test case ("Test"); ut test (Test1 test case , "Error Reproduce", Expr( ut assert that(Expr(test1({"a","b",.})),1) // => 1 Contains only strings ));

If I run this test I will get a failure, the result of the test is: „Actual: was 0“ but it should be „Actual: 1“ as above!

Now I am changing the Code of my function in the third line by replacing "value" with "xvalue" (or something else):

test1 = function( {input},{default local}, input = Filter Each({x}, input, !(IsMissing(x)==1)); if(input == Filter Each({xvalue},input, Is String(xvalue)==1), return (1), // Exit if filtered list contains only strings return (0)); // Exit if filtered list contains other items );

Then I am executing the same test function again. Now it works and shows the right test result!
Note that the same function works regardless the Filter Each-variable name is "value" or something else!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions