-- Parsing SCXML into states and transitions.
-- Error CONTEXT carries plpgsql line numbers, which would make this
-- expected output break on every unrelated edit.
\set SHOW_CONTEXT never
-- Quiet, so that the expected output is the same whether or not an earlier
-- test in the same database already created the extension.
set client_min_messages to warning;
create extension if not exists pg_statecharts_dev cascade;
reset client_min_messages;
\set chart ''
-- States come out in document order, with parent_id and is_initial resolved
-- from the enclosing element. Every child of a is initial.
select id, name, parent_id, is_initial, is_final, on_entry::text, on_exit::text
from fsm.scxml_states(:'chart'::xml);
-- Transitions belong to the state that encloses them. The
-- transitions and anything under a must not appear here.
select event, source_state, target_state from fsm.scxml_transitions(:'chart'::xml);
-- A dotted src is split on the first dot, an undotted one defaults to public
select (fsm.scxml_states(
'
'::xml)).on_entry::text as callbacks;
-- XML entities in attributes have to be decoded, not passed through escaped
select id, name from fsm.scxml_states(
'
'::xml);
-- Namespaceless documents are accepted too
select id from fsm.scxml_states(
''::xml);
-- An unnamed state gets an empty name rather than being rejected
select id, name = '' as name_is_empty from fsm.scxml_states(
''::xml);
--
-- Error cases
--
-- compound state without an
select fsm.scxml_states(
'
'::xml);
-- pointing at a state that is not a child
select fsm.scxml_states(
'
'::xml);
-- root initial pointing at nothing
select fsm.scxml_states(
''::xml);
-- state without an id
select fsm.scxml_states(
''::xml);
-- no states at all
select fsm.scxml_states(''::xml);
-- no initial attribute
select fsm.scxml_states(''::xml);
-- A transition without an event, or without a target, is rejected by name.
-- fsm.transition has NOT NULL on both, and a NULL here used to make the
-- generator's string_agg silently drop the row from the migration.
select fsm.scxml_transitions(
'
'::xml);
select fsm.scxml_transitions(
'
'::xml);
-- A transition inside used to be silently excluded by the xpath; the
-- runtime would refuse the chart at insert time, so the generator has to too.
select fsm.scxml_transitions(
'
'::xml);