Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Add test and update comments on bind scope (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Nov 19, 2021
1 parent dc79e40 commit 3f23dbf
Showing 1 changed file with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,46 @@ public void doListPathWithDots() {
});
}

@Test
public void doListOnObjects() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"set_array('author[]')",
"copy_field('creator.name', 'author[].name')",
"do list('path': 'author[]', 'var': 'a')",
" add_field('a.type', 'Default')",
"end",
"remove_field('creator')"),
i -> {
i.startRecord("1");
i.startEntity("creator");
i.literal("name", "A University");
i.endEntity();
i.startEntity("creator");
i.literal("name", "Max");
i.endEntity();
i.endRecord();
}, (o, f) -> {
o.get().startRecord("1");
o.get().startEntity("author[]");
o.get().startEntity("1");
o.get().literal("name", "A University");
o.get().literal("type", "Default");
o.get().endEntity();
o.get().startEntity("2");
o.get().literal("name", "Max");
o.get().literal("type", "Default");
f.apply(2).endEntity();
o.get().endRecord();
});
}

@Test
public void doListWithAppendAndLast() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
// TODO: this example makes no sense?
// For each creator, we create a new array?
// The $last picks the last of the full array
// TODO consistent handling of .1, .*, .$last, .$append
"do list('path': 'creator', 'var': 'c')",
" set_array('author[]')",
" copy_field('c.name', 'author[].$append.name')",
Expand All @@ -119,7 +156,7 @@ public void doListWithAppendAndLast() {
o.get().startEntity("author[]");
o.get().startEntity("1");
o.get().literal("name", "A University");
// o.get().literal("type", "Default"); // FIXME: bind scope broken
// o.get().literal("type", "Default"); // FIXME: bind scope broken?
o.get().endEntity();
o.get().startEntity("2");
o.get().literal("name", "Max");
Expand Down

0 comments on commit 3f23dbf

Please sign in to comment.