From: Nicolas Luck Date: Tue, 30 Jan 2024 11:54:12 +0000 (+0100) Subject: Adjust some first result orderings in integration assertions X-Git-Tag: v0.9.4~3^2~22 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=48b2379fe559b6e8fc170b3947c54b0f07e0b933;p=scryer-prolog.git Adjust some first result orderings in integration assertions --- diff --git a/src/machine/lib_integration_test_commands.txt b/src/machine/lib_integration_test_commands.txt index f838c867..e2c7328e 100644 --- a/src/machine/lib_integration_test_commands.txt +++ b/src/machine/lib_integration_test_commands.txt @@ -257,19 +257,19 @@ subject_class("Todo", C), property_resolve_language(C, "title", Language). =====query subject_class("Todo", C), collection(C, Collection). =====result -[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"likedMessages"},{"C":"c","Collection":"messages"}] +[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"messages"},{"C":"c","Collection":"likedMessages"}] =====query subject_class("Todo", C), collection_adder(C, Collection, Adder). =====result -[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"}] +[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"}] =====query subject_class("Todo", C), collection_remover(C, Collection, Remover). =====result -[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), collection_setter(C, Collection, Setter). =====result -[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), instance(C, "literal://string:construct%20test"). =====result @@ -384,7 +384,7 @@ subject_class("Todo", C), instance(C, "literal://string:get%20proxy%20test"). =====query subject_class("Todo", C), property(C, Property). =====result -[{"C":"c","Property":"isLiked"},{"C":"c","Property":"state"},{"C":"c","Property":"title"}] +[{"C":"c","Property":"state"},{"C":"c","Property":"title"},{"C":"c","Property":"isLiked"}] =====query subject_class("Todo", C), property_resolve(C, "isLiked"). =====result @@ -412,19 +412,19 @@ subject_class("Todo", C), property_resolve_language(C, "title", Language). =====query subject_class("Todo", C), collection(C, Collection). =====result -[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"likedMessages"},{"C":"c","Collection":"messages"}] +[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"messages"},{"C":"c","Collection":"likedMessages"}] =====query subject_class("Todo", C), collection_adder(C, Collection, Adder). =====result -[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"}] +[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"}] =====query subject_class("Todo", C), collection_remover(C, Collection, Remover). =====result -[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), collection_setter(C, Collection, Setter). =====result -[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), instance(C, "literal://string:get%20proxy%20test"). =====result @@ -436,7 +436,7 @@ subject_class("Todo", C), instance(C, "literal://string:get%20proxy%20test"). =====query subject_class("Todo", C), property(C, Property). =====result -[{"C":"c","Property":"isLiked"},{"C":"c","Property":"state"},{"C":"c","Property":"title"}] +[{"C":"c","Property":"state"},{"C":"c","Property":"title"},{"C":"c","Property":"isLiked"}] =====query subject_class("Todo", C), property_resolve(C, "isLiked"). =====result @@ -464,29 +464,29 @@ subject_class("Todo", C), property_resolve_language(C, "title", Language). =====query subject_class("Todo", C), collection(C, Collection). =====result -[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"likedMessages"},{"C":"c","Collection":"messages"}] +[{"C":"c","Collection":"comments"},{"C":"c","Collection":"entries"},{"C":"c","Collection":"messages"},{"C":"c","Collection":"likedMessages"}] =====query subject_class("Todo", C), collection_adder(C, Collection, Adder). =====result -[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"}] +[{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]","C":"c","Collection":"commentss"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"entriess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"messagess"},{"Adder":"[{action: \"addLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]","C":"c","Collection":"likedMessagess"}] =====query subject_class("Todo", C), collection_remover(C, Collection, Remover). =====result -[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Remover":"[{action: \"removeLink\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), collection_setter(C, Collection, Setter). =====result -[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] +[{"C":"c","Collection":"commentss","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"todo://comment\", target: \"value\"}]"},{"C":"c","Collection":"entriess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"messagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"},{"C":"c","Collection":"likedMessagess","Setter":"[{action: \"collectionSetter\", source: \"this\", predicate: \"flux://entry_type\", target: \"value\"}]"}] =====query subject_class("Todo", C), property_getter(C, "literal://string:get%20proxy%20test", "state", Value). -=====query -subject_class("Todo", C), property_getter(C, "literal://string:get%20proxy%20test", "title", Value). =====result [{"C":"c","Value":"todo://ready"}] =====query -subject_class("Todo", C), constructor(C, Actions). +subject_class("Todo", C), property_getter(C, "literal://string:get%20proxy%20test", "title", Value). =====result false +=====query +subject_class("Todo", C), constructor(C, Actions). =====result [{"Actions":"[{action: \"addLink\", source: \"this\", predicate: \"todo://state\", target: \"todo://ready\"}]","C":"c"}] =====consult @@ -589,15 +589,15 @@ collection_setter(c, "likedMessagess", '[{action: "collectionSetter", source: "t =====query subject_class("Todo", C), instance(C, "literal://string:construct%20test"). =====result -[{"C":"c"},{"C":"c"}] +[{"C":"c"}] =====query subject_class("Todo", C), instance(C, "literal://string:construct%20test"). =====result -[{"C":"c"},{"C":"c"}] +[{"C":"c"}] =====query subject_class("Todo", C), property(C, Property). =====result -[{"C":"c","Property":"isLiked"},{"C":"c","Property":"state"},{"C":"c","Property":"title"}] +[{"C":"c","Property":"state"},{"C":"c","Property":"title"},{"C":"c","Property":"isLiked"}] =====query subject_class("Todo", C), property_resolve(C, "isLiked"). =====result diff --git a/src/machine/lib_machine.rs b/src/machine/lib_machine.rs index 5f34f127..28d997c7 100644 --- a/src/machine/lib_machine.rs +++ b/src/machine/lib_machine.rs @@ -475,22 +475,18 @@ mod tests { // Check if the block is a query if let Some(query) = block.strip_prefix("query") { - i += 1; - println!("query #{}: {}", i, query); // Parse and execute the query let result = machine.run_query(query.to_string()); - // Print the result - println!("{:?}", result); assert!(result.is_ok()); last_result = Some(result); } else if let Some(code) = block.strip_prefix("consult") { - println!("load code: {}", code); - // Load the code into the machine machine.consult_module_string("facts", code.to_string()); } else if let Some(result) = block.strip_prefix("result") { + i += 1; if let Some(Ok(ref last_result)) = last_result { + println!("\n\n=====Result No. {}=======\n{}\n===============", i, last_result.to_string().trim()); assert_eq!(last_result.to_string().trim(), result.to_string().trim(),) } }