From 3a0e0aa42d2f507dc9516da13ed384b31eeb9c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 6 Feb 2025 18:23:44 +0100 Subject: [PATCH 1/5] Only use current fix examples for tests #633 --- .../metafacture/metafix/FixParsingTest.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/metafix/src/test/java/org/metafacture/metafix/FixParsingTest.java b/metafix/src/test/java/org/metafacture/metafix/FixParsingTest.java index cc2607b0f..86175cd23 100644 --- a/metafix/src/test/java/org/metafacture/metafix/FixParsingTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/FixParsingTest.java @@ -29,7 +29,7 @@ public FixParsingTest() { @Test public void shouldParseSimple() throws Exception { parse( - "map(a,b)" + "copy_field(a,b)" ); } @@ -41,7 +41,9 @@ public void shouldParseQuotedStrings() throws Exception { "add_field(hello,\"w-o:r l/d\")", "add_field(hello,'\tw\n\torld')", "add_field(hello,'\\tw\\n\\torld')", - "add_field(hello,'\"world\"')" + "add_field(hello,'\"world\"')", + "add_field(\"hello\",world)", + "add_field('hello','world')" ); } @@ -50,17 +52,17 @@ public void shouldParseMappings() throws Exception { parse( "# simple field name mappings", "", - "map(a,b)", + "copy_field(a,b)", "", "# nested field structure", "", - "map(e1)", - "map(e1.e2)", - "map(e1.e2.d)", + "copy_field(e1,f1)", + "copy_field(e1.e2,f1)", + "copy_field(e1.e2.d,f1)", "", - "# pass-through for unmapped fields", + "# pass-through for fields by default, use retain to only keep certain elements", "", - "map(_else)", + "retain(f1, b)", "" ); } @@ -90,15 +92,15 @@ public void shouldParseTransformations() throws Exception { "", "# Loops", "", - "do list(path)", + "do list(path:'test')", "\tadd_field(foo,bar)", LITERAL_END, "", "# Nested expressions", "", - "do marc_each()", - "\tif marc_has(f700)", - "\t\tmarc_map(f700a,authors.$append)", + "do list(path:'700??','var':'$i')", + "\tif any_match('$i.4','aut')", + "\t\tcopy_field('$i.a','authors.$append')", "\t" + LITERAL_END, LITERAL_END, "" From 657fbce15b40037c424dfb0374077d4108949d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 6 Feb 2025 18:26:17 +0100 Subject: [PATCH 2/5] Only use current fix examples for tests in README #633 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2cfcbcda..6a3196c7c 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ Content assist is triggered with Ctrl-Space. The input above is also used in `Fi Run workflows on the web server, passing `data`, `flux`, and `fix`: -[http://localhost:8080/xtext-service/run?data='1'{'a': '5', 'z': 10}&flux=as-lines|decode-formeta|fix|encode-formeta(style="multiline")&fix=map(a,b) map(\_else)](http://localhost:8080/xtext-service/run?data=%271%27{%27a%27:%20%275%27,%20%27z%27:%2010}&flux=as-lines|decode-formeta|fix|encode-formeta(style=%22multiline%22)&fix=map(a,c)%20map(\_else)) +[http://localhost:8080/xtext-service/run?data='1'{'a': '5', 'z': 10}&flux=as-lines|decode-formeta|fix|encode-formeta(style="multiline")&fix=copy_field(a,c)](http://localhost:8080/xtext-service/run?data=%271%27{%27a%27:%20%275%27,%20%27z%27:%2010}&flux=as-lines|decode-formeta|fix|encode-formeta(style=%22multiline%22)&fix=copy_field(a,c)) ## Functions and cookbook From 39ce013e731250b20698b61455733fadd80ae651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 6 Feb 2025 18:35:36 +0100 Subject: [PATCH 3/5] Only use current fix examples for sample #633 --- misc/vim/syntax/syntax-sample.fix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/vim/syntax/syntax-sample.fix b/misc/vim/syntax/syntax-sample.fix index ebe91dcad..2aed41d2a 100644 --- a/misc/vim/syntax/syntax-sample.fix +++ b/misc/vim/syntax/syntax-sample.fix @@ -25,15 +25,15 @@ end # Loops -do list(path) +do list(path:"base") add_field(foo, bar) and foo.bar(key: "val=$1") end # Nested expressions -do marc_each() - if marc_has(f700) - marc_map(f700a, authors.$append.bla, 'bla') +do list(path:"700","var":"$i") + if any_equal("$i.4","aut") + copy_field("$i.a", "authors.$append") end end From 76e80ccddb911042a456798f25bb2ff46d6c4546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 6 Feb 2025 18:38:09 +0100 Subject: [PATCH 4/5] Only use current fix examples for tests #633 --- .../test/java/org/metafacture/metafix/InterpreterTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metafix/src/test/java/org/metafacture/metafix/InterpreterTest.java b/metafix/src/test/java/org/metafacture/metafix/InterpreterTest.java index afc3ac24e..6a99adb15 100644 --- a/metafix/src/test/java/org/metafacture/metafix/InterpreterTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/InterpreterTest.java @@ -38,9 +38,9 @@ public void shouldInterpretSimple() throws Exception { @Test public void shouldInterpretNested() throws Exception { interpret(3, - "do marc_each()", - "\tif marc_has(f700)", - "\t\tmarc_map(f700a,authors.$append)", + "do list(path:'700??','var':'$i')", + "\tif any_equal('$i.4','aut')", + "\t\tcopy_field($i.a,authors.$append)", "\tend", "end", "" From d3a0ad547cfc4ffc6f80d65eb7bff1b08e1f5e07 Mon Sep 17 00:00:00 2001 From: TobiasNx <61879957+TobiasNx@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:13:02 +0100 Subject: [PATCH 5/5] Delete old morph inspired tests #633 --- .../metafacture/metafix/MetafixBindTest.java | 129 ------------------ 1 file changed, 129 deletions(-) diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java index 21277696a..3527a54f3 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java @@ -539,135 +539,6 @@ public void doListIndexedArrayOfObjectsToArrayOfObjects() { }); } - @Test - @MetafixToDo("implement Fix-style binds with collectors?") - public void ifInCollector() { - MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "do entity('author')", - " map('name')", - " if all_contain('name', 'University')", - " add_field('type', 'Organization')", - " end", - "end"), - i -> { - i.startRecord("1"); - i.literal("name", "A University"); - i.endRecord(); - }, o -> { - o.get().startRecord("1"); - o.get().startEntity("author"); - o.get().literal("type", "Organization"); - o.get().literal("name", "A University"); - o.get().endEntity(); - o.get().endRecord(); - }); - } - - @Test - @MetafixToDo("implement Fix-style binds with collectors?") - public void ifInCollectorMultiRecords() { - MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "do entity('author')", - " map('name')", - " if all_contain('name', 'University')", - " add_field('type', 'Organization')", - " end", - "end"), - i -> { - i.startRecord("1"); - i.literal("name", "Max"); - i.endRecord(); - - i.startRecord("2"); - i.literal("name", "A University"); - i.endRecord(); - - i.startRecord("3"); - i.literal("name", "Mary"); - i.endRecord(); - }, o -> { - o.get().startRecord("1"); - o.get().startEntity("author"); - o.get().literal("name", "Max"); - o.get().endEntity(); - o.get().endRecord(); - - o.get().startRecord("2"); - o.get().startEntity("author"); - o.get().literal("type", "Organization"); - o.get().literal("name", "A University"); - o.get().endEntity(); - o.get().endRecord(); - - o.get().startRecord("3"); - o.get().startEntity("author"); - o.get().literal("name", "Mary"); - o.get().endEntity(); - o.get().endRecord(); - }); - } - - @Test - @MetafixToDo("implement Fix-style binds with collectors?") - public void ifInCollectorChoose() { - MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "do choose(flushWith: 'record')", - " if all_contain('name', 'University')", - " add_field('type', 'Organization')", - " end", - "end"), - i -> { - i.startRecord("1"); - i.literal("name", "Max University"); - i.endRecord(); - - i.startRecord("2"); - i.literal("name", "Max Musterman"); - i.endRecord(); - }, o -> { - o.get().startRecord("1"); - o.get().literal("type", "Organization"); - o.get().endRecord(); - - o.get().startRecord("2"); - o.get().endRecord(); - }); - } - - @Test - @MetafixToDo("implement Fix-style binds with collectors?") - public void ifInCollectorCombine() { - MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "do combine(name: 'fullName', value: '${first} ${last}')", - " if all_contain('author.type', 'Person')", - " map('author.first', 'first')", - " map('author.last', 'last')", - " end", - "end"), - i -> { - i.startRecord("1"); - i.startEntity("author"); - i.literal("type", "Organization"); - i.endEntity(); - i.endRecord(); - - i.startRecord("2"); - i.startEntity("author"); - i.literal("first", "Max"); - i.literal("last", "Musterman"); - i.literal("type", "DifferentiatedPerson"); - i.endEntity(); - i.endRecord(); - }, o -> { - o.get().startRecord("1"); - o.get().endRecord(); - - o.get().startRecord("2"); - o.get().literal("fullName", "Max Musterman"); - o.get().endRecord(); - }); - } - private void shouldIterateOverList(final String path, final int expectedCount) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "set_array('trace')",