Power-Fx icon indicating copy to clipboard operation
Power-Fx copied to clipboard

Update function

Open pooya1380m opened this issue 2 years ago • 7 comments

Update function #1000

I implemented the Update function but I don't now how to write Update.txt , I don't know how test.txt work can some body explain it for me

pooya1380m avatar Dec 11 '23 16:12 pooya1380m

@microsoft-github-policy-service agree

pooya1380m avatar Dec 11 '23 16:12 pooya1380m

Thanks for your PR! Regarding the txt file test, please create a new Update.txt file at ...src\tests\Microsoft.PowerFx.Core.Tests\ExpressionTestCases. The syntax should be

>> POWER-FX_EXPRESSION_1
EXPECTED_RESULT_1

>> POWER-FX_EXPRESSION_2
EXPECTED_RESULT_2

.
.
.

>> POWER-FX_EXPRESSION_N
EXPECTED_RESULT_N

The test framework should catch the file automatically and run the expressions in it.

anderson-joyle avatar Dec 11 '23 17:12 anderson-joyle

Thanks @anderson-joyle

Patch(t1, r1, {Field2:"mars"}); t1 Table({Field1:1,Field2:"mars",Field3:DateTime(2022,1,1,0,0,0,0),Field4:true})

How does this work?

pooya1380m avatar Dec 11 '23 17:12 pooya1380m

@pooya1380m - thanks for the contribution. I'm curious - are you using Power Fx libraries for something?

MikeStall avatar Dec 11 '23 17:12 MikeStall

At the top of Patch.txt file we have MutationFunctionsTestSetup setup. You can check its implementation here: https://github.com/microsoft/Power-Fx/blob/c37f0963973b1ad80e829f0c8bb80567bfcb805d/src/tests/Microsoft.PowerFx.Interpreter.Tests/PowerFxEvaluationTests.cs#L146C13-L146C13

This setup creates a table variable t1 populated with some records in advance. We can then reference t1 within the txt test file.

Please also check txt files at ...src\tests\Microsoft.PowerFx.Interpreter.Tests\MutationScripts. The big difference is that here the result from an expression persists to the next one.

anderson-joyle avatar Dec 11 '23 17:12 anderson-joyle

@pooya1380m - thanks for the contribution. I'm curious - are you using Power Fx libraries for something? No I'm interested in the concept of Power Fx and would like to contribute to it

pooya1380m avatar Dec 11 '23 17:12 pooya1380m

Hi @anderson-joyle I want to know if I used the correct black value for my tests ? and Im doing it in right way?

pooya1380m avatar Dec 22 '23 07:12 pooya1380m