Skip to content

Commit f180907

Browse files
authored
Merge pull request #665 from metafacture/633-oldSyntax
Only use current fix examples for tests #633
2 parents cd97ee4 + d3a0ad5 commit f180907

File tree

5 files changed

+22
-149
lines changed

5 files changed

+22
-149
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Content assist is triggered with Ctrl-Space. The input above is also used in `Fi
189189
190190
Run workflows on the web server, passing `data`, `flux`, and `fix`:
191191
192-
[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))
192+
[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))
193193
194194
## Functions and cookbook
195195

metafix/src/test/java/org/metafacture/metafix/FixParsingTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public FixParsingTest() {
2929
@Test
3030
public void shouldParseSimple() throws Exception {
3131
parse(
32-
"map(a,b)"
32+
"copy_field(a,b)"
3333
);
3434
}
3535

@@ -41,7 +41,9 @@ public void shouldParseQuotedStrings() throws Exception {
4141
"add_field(hello,\"w-o:r l/d\")",
4242
"add_field(hello,'\tw\n\torld')",
4343
"add_field(hello,'\\tw\\n\\torld')",
44-
"add_field(hello,'\"world\"')"
44+
"add_field(hello,'\"world\"')",
45+
"add_field(\"hello\",world)",
46+
"add_field('hello','world')"
4547
);
4648
}
4749

@@ -50,17 +52,17 @@ public void shouldParseMappings() throws Exception {
5052
parse(
5153
"# simple field name mappings",
5254
"",
53-
"map(a,b)",
55+
"copy_field(a,b)",
5456
"",
5557
"# nested field structure",
5658
"",
57-
"map(e1)",
58-
"map(e1.e2)",
59-
"map(e1.e2.d)",
59+
"copy_field(e1,f1)",
60+
"copy_field(e1.e2,f1)",
61+
"copy_field(e1.e2.d,f1)",
6062
"",
61-
"# pass-through for unmapped fields",
63+
"# pass-through for fields by default, use retain to only keep certain elements",
6264
"",
63-
"map(_else)",
65+
"retain(f1, b)",
6466
""
6567
);
6668
}
@@ -90,15 +92,15 @@ public void shouldParseTransformations() throws Exception {
9092
"",
9193
"# Loops",
9294
"",
93-
"do list(path)",
95+
"do list(path:'test')",
9496
"\tadd_field(foo,bar)",
9597
LITERAL_END,
9698
"",
9799
"# Nested expressions",
98100
"",
99-
"do marc_each()",
100-
"\tif marc_has(f700)",
101-
"\t\tmarc_map(f700a,authors.$append)",
101+
"do list(path:'700??','var':'$i')",
102+
"\tif any_match('$i.4','aut')",
103+
"\t\tcopy_field('$i.a','authors.$append')",
102104
"\t" + LITERAL_END,
103105
LITERAL_END,
104106
""

metafix/src/test/java/org/metafacture/metafix/InterpreterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public void shouldInterpretSimple() throws Exception {
3838
@Test
3939
public void shouldInterpretNested() throws Exception {
4040
interpret(3,
41-
"do marc_each()",
42-
"\tif marc_has(f700)",
43-
"\t\tmarc_map(f700a,authors.$append)",
41+
"do list(path:'700??','var':'$i')",
42+
"\tif any_equal('$i.4','aut')",
43+
"\t\tcopy_field($i.a,authors.$append)",
4444
"\tend",
4545
"end",
4646
""

metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -539,135 +539,6 @@ public void doListIndexedArrayOfObjectsToArrayOfObjects() {
539539
});
540540
}
541541

542-
@Test
543-
@MetafixToDo("implement Fix-style binds with collectors?")
544-
public void ifInCollector() {
545-
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
546-
"do entity('author')",
547-
" map('name')",
548-
" if all_contain('name', 'University')",
549-
" add_field('type', 'Organization')",
550-
" end",
551-
"end"),
552-
i -> {
553-
i.startRecord("1");
554-
i.literal("name", "A University");
555-
i.endRecord();
556-
}, o -> {
557-
o.get().startRecord("1");
558-
o.get().startEntity("author");
559-
o.get().literal("type", "Organization");
560-
o.get().literal("name", "A University");
561-
o.get().endEntity();
562-
o.get().endRecord();
563-
});
564-
}
565-
566-
@Test
567-
@MetafixToDo("implement Fix-style binds with collectors?")
568-
public void ifInCollectorMultiRecords() {
569-
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
570-
"do entity('author')",
571-
" map('name')",
572-
" if all_contain('name', 'University')",
573-
" add_field('type', 'Organization')",
574-
" end",
575-
"end"),
576-
i -> {
577-
i.startRecord("1");
578-
i.literal("name", "Max");
579-
i.endRecord();
580-
581-
i.startRecord("2");
582-
i.literal("name", "A University");
583-
i.endRecord();
584-
585-
i.startRecord("3");
586-
i.literal("name", "Mary");
587-
i.endRecord();
588-
}, o -> {
589-
o.get().startRecord("1");
590-
o.get().startEntity("author");
591-
o.get().literal("name", "Max");
592-
o.get().endEntity();
593-
o.get().endRecord();
594-
595-
o.get().startRecord("2");
596-
o.get().startEntity("author");
597-
o.get().literal("type", "Organization");
598-
o.get().literal("name", "A University");
599-
o.get().endEntity();
600-
o.get().endRecord();
601-
602-
o.get().startRecord("3");
603-
o.get().startEntity("author");
604-
o.get().literal("name", "Mary");
605-
o.get().endEntity();
606-
o.get().endRecord();
607-
});
608-
}
609-
610-
@Test
611-
@MetafixToDo("implement Fix-style binds with collectors?")
612-
public void ifInCollectorChoose() {
613-
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
614-
"do choose(flushWith: 'record')",
615-
" if all_contain('name', 'University')",
616-
" add_field('type', 'Organization')",
617-
" end",
618-
"end"),
619-
i -> {
620-
i.startRecord("1");
621-
i.literal("name", "Max University");
622-
i.endRecord();
623-
624-
i.startRecord("2");
625-
i.literal("name", "Max Musterman");
626-
i.endRecord();
627-
}, o -> {
628-
o.get().startRecord("1");
629-
o.get().literal("type", "Organization");
630-
o.get().endRecord();
631-
632-
o.get().startRecord("2");
633-
o.get().endRecord();
634-
});
635-
}
636-
637-
@Test
638-
@MetafixToDo("implement Fix-style binds with collectors?")
639-
public void ifInCollectorCombine() {
640-
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
641-
"do combine(name: 'fullName', value: '${first} ${last}')",
642-
" if all_contain('author.type', 'Person')",
643-
" map('author.first', 'first')",
644-
" map('author.last', 'last')",
645-
" end",
646-
"end"),
647-
i -> {
648-
i.startRecord("1");
649-
i.startEntity("author");
650-
i.literal("type", "Organization");
651-
i.endEntity();
652-
i.endRecord();
653-
654-
i.startRecord("2");
655-
i.startEntity("author");
656-
i.literal("first", "Max");
657-
i.literal("last", "Musterman");
658-
i.literal("type", "DifferentiatedPerson");
659-
i.endEntity();
660-
i.endRecord();
661-
}, o -> {
662-
o.get().startRecord("1");
663-
o.get().endRecord();
664-
665-
o.get().startRecord("2");
666-
o.get().literal("fullName", "Max Musterman");
667-
o.get().endRecord();
668-
});
669-
}
670-
671542
private void shouldIterateOverList(final String path, final int expectedCount) {
672543
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
673544
"set_array('trace')",

misc/vim/syntax/syntax-sample.fix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ end
2525

2626
# Loops
2727

28-
do list(path)
28+
do list(path:"base")
2929
add_field(foo, bar) and foo.bar(key: "val=$1")
3030
end
3131

3232
# Nested expressions
3333

34-
do marc_each()
35-
if marc_has(f700)
36-
marc_map(f700a, authors.$append.bla, 'bla')
34+
do list(path:"700","var":"$i")
35+
if any_equal("$i.4","aut")
36+
copy_field("$i.a", "authors.$append")
3737
end
3838
end
3939

0 commit comments

Comments
 (0)