On Sat, Jan 7, 2017 at 3:52 AM, Kirk Brooks <[email protected]> wrote:

> I think what David is trying to do is something like this:
>
> $code:="$text:=\"\"damn\" dog \\on hill\r\n"
> $code:=$code+"ALERT(___escape ($text)+\"\r\r\"+$text)"
>
> and then run $code.
>
>
> ​In this context the method makes sense. I've found it challenging to have
> 4D write 4D code for anything beyond fairly simple structures for reasons
> just like this - it becomes really hard to debug and verify.
>
>
Yes, exactly. I need to defeat 4D's automatic escaping. I'm not using it
for SET METHOD CODE in this case, although that's a feature I lean on
pretty heavily in my work. In this situation I'm setting up automatic test
cases and want to seed the data with determined known outcomes. I've been
doing a lot of work with, reading about, and thinking about automated tests
over the past few months...and spent about a week with an inspirational
group up in Brisbane exploring ideas and options last month. In any case,
I'm bringing my tools up to date.

Out of interest, is automated testing in 4D an area of interest to many?
And, yes, I'm aware of Mark Schaake's unit testing component:

https://github.com/markschaake/UnitTester4D

I greatly admire what Mark accomplished and how beautiful the tool
looks...but I'm not using it for a variety of reasons.

In any case, automated tests have at their heart the comparison of a known
good output (value, value in a range, complex result, image) that you
compare with a live output. I've got various routines that produce C_OBJECT
results that I want to seed my system with. So, serialize the object,
escape the text and then you get something like this:

C_TEXT($expected_good_object_with_name)
$expected_good_object_with_name:="{\n\t\"header\": {\n\t\t\"type_name\":
\"Foo_Object\",\n\t\t\"version_number\": 1.1,\n\t\t\"instance_name\":
\"Test instance\"\n\t},\n\t\"body\": {}\n}"

Yeah, I'm going to write that sort of code by hand. Not. I run the test,
get the actual result and a 'fail' because I don't know what to expect. I
check the output, see that it's right and then escape it back into the seed
method. Rebuild the test case, run, it passes. Going forward, if I change
something somewhere and the case breaks, I'll know.

I build test cases a lot of different ways...this is just one.

Anyway, that's what I'm up to in this case and figured someone else might
sometime need to escape escape characters.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to