preparing for deeper testing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-06-28 20:38:28 +03:00
parent 49ee54539f
commit a4453e18a4
4 changed files with 55 additions and 30 deletions

7
v3/package-lock.json generated
View File

@ -13,6 +13,7 @@
"ig-actions": "*", "ig-actions": "*",
"ig-features": "*", "ig-features": "*",
"ig-object": "*", "ig-object": "*",
"ig-serialize": "*",
"ig-types": "*", "ig-types": "*",
"requirejs": "*", "requirejs": "*",
"uuid": "*" "uuid": "*"
@ -141,6 +142,12 @@
"ig-stoppable": "^2.0.0" "ig-stoppable": "^2.0.0"
} }
}, },
"node_modules/ig-serialize": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/ig-serialize/-/ig-serialize-1.3.4.tgz",
"integrity": "sha512-aIrZ7ljyXVRUsyvcWfF2JSz/4hWtDrJcTpHJ2y4QD48YXF/0eIwwzDbB6dCmoK2EO5fHfxa82WrVBncb+kDqvg==",
"license": "BSD-3-Clause"
},
"node_modules/ig-stoppable": { "node_modules/ig-stoppable": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/ig-stoppable/-/ig-stoppable-2.0.4.tgz", "resolved": "https://registry.npmjs.org/ig-stoppable/-/ig-stoppable-2.0.4.tgz",

View File

@ -11,7 +11,8 @@
"ig-actions": "*", "ig-actions": "*",
"ig-features": "*", "ig-features": "*",
"ig-object": "*", "ig-object": "*",
"ig-types": "*" "ig-types": "*",
"ig-serialize": "*"
}, },
"devDependencies": { "devDependencies": {
"ig-test": "*" "ig-test": "*"

View File

@ -1355,10 +1355,15 @@ module.parser = {
// XXX need a way to make encode option transparent... // XXX need a way to make encode option transparent...
// XXX store a page cache in state... // XXX store a page cache in state...
// XXX UPDATE... // XXX UPDATE...
include2: Macro(
['src', 'recursive', 'join',
['s', 'strict', 'isolated']],
function*(parser, args, body, state, key='included', handler){
}),
include: Macro( include: Macro(
['src', 'recursive', 'join', ['src', 'recursive', 'join',
['s', 'strict', 'isolated']], ['s', 'strict', 'isolated']],
async function*(args, body, state, key='included', handler){ async function*(parser, args, body, state, key='included', handler){
var macro = 'include' var macro = 'include'
if(typeof(args) == 'string'){ if(typeof(args) == 'string'){
var [macro, args, body, state, key, handler] = arguments var [macro, args, body, state, key, handler] = arguments

View File

@ -2,6 +2,7 @@
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var test = require('ig-test') var test = require('ig-test')
var serialize = require('ig-serialize')
var parser = require('../parser').parser var parser = require('../parser').parser
@ -10,10 +11,15 @@ var parser = require('../parser').parser
test.Setups({ test.Setups({
empty: function(assert){ empty: function(assert){
return [ '', '' ] }, return { code: [ '', '' ] }},
// XXX var...
// XXX arg...
// slot...
slot_empty: function(assert){ slot_empty: function(assert){
return [ return {code: [
'@slot(slot)', '@slot(slot)',
'@slot("slot")', '@slot("slot")',
'@slot(\'slot\')', '@slot(\'slot\')',
@ -26,44 +32,44 @@ test.Setups({
'<slot name=slot/>', '<slot name=slot/>',
'<slot name="slot"/>', '<slot name="slot"/>',
'<slot name=\'slot\'/>', '<slot name=\'slot\'/>',
'' ] }, '' ]} },
slot_value: function(assert){ slot_value: function(assert){
return [ return {code: [
'<slot slot value/>', '<slot slot value/>',
'<slot slot text=value/>', '<slot slot text=value/>',
'@slot(slot value)', '@slot(slot value)',
'@slot(slot text=value)', '@slot(slot text=value)',
'value' ] }, 'value' ]} },
slot_fill: function(assert){ slot_fill: function(assert){
var ins = this.slot_value(assert).slice(0, -1) var ins = this.slot_value(assert).code.slice(0, -1)
return [ return {code: [
...ins.map(function(e){ ...ins.map(function(e){
return e + '@slot(slot other)' }), return e + '@slot(slot other)' }),
...ins.map(function(e){ ...ins.map(function(e){
return e + '<slot slot other/>' }), return e + '<slot slot other/>' }),
...ins.map(function(e){ ...ins.map(function(e){
return e + '<slot slot>other</slot>' }), return e + '<slot slot>other</slot>' }),
'other' ] }, 'other' ]} },
slot_fill_fill: function(assert){ slot_fill_fill: function(assert){
var ins = this.slot_fill(assert).slice(0, -1) var ins = this.slot_fill(assert).code.slice(0, -1)
return [ return {code: [
...ins.map(function(e){ ...ins.map(function(e){
return e + '@slot(slot third)' }), return e + '@slot(slot third)' }),
...ins.map(function(e){ ...ins.map(function(e){
return e + '<slot slot third/>' }), return e + '<slot slot third/>' }),
...ins.map(function(e){ ...ins.map(function(e){
return e + '<slot slot>third</slot>' }), return e + '<slot slot>third</slot>' }),
'third' ] }, 'third' ]} },
// XXX these are an alternative to <content/>... // XXX these are an alternative to <content/>...
slot_nested: function(assert){ slot_nested: function(assert){
return [ return {code: [
'<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot.content value)', '<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot.content value)',
'[[ value ]]' ] }, '[[ value ]]' ]} },
slot_nested_overwrite: function(assert){ slot_nested_overwrite: function(assert){
return [ return {code: [
'<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot value)', '<slot slot>[[ <slot slot.content/> ]]</slot>@slot(slot value)',
'value' ] }, 'value' ]} },
/* XXX SHOWN_HIDDEN /* XXX SHOWN_HIDDEN
// XXX these need to be revised... // XXX these need to be revised...
@ -72,29 +78,29 @@ test.Setups({
slot_shown: function(assert){ slot_shown: function(assert){
var ins = this.slot_value(assert) var ins = this.slot_value(assert)
var expect = ins.pop() var expect = ins.pop()
return [ return {code: [
...ins.map(function(i){ ...ins.map(function(i){
return i +' @slot(slot that shown)' }), return i +' @slot(slot that shown)' }),
'that that' ] }, 'that that' ]} },
slot_hidden: function(assert){ slot_hidden: function(assert){
return [ return {code: [
'<slot slot value hidden/>', '<slot slot value hidden/>',
'@slot(slot value hidden)', '@slot(slot value hidden)',
'' ] }, '' ]} },
slot_hidden_value: function(assert){ slot_hidden_value: function(assert){
var ins = this.slot_hidden(assert) var ins = this.slot_hidden(assert)
var expect = ins.pop() var expect = ins.pop()
return [ return {code: [
...ins.map(function(i){ ...ins.map(function(i){
return i +'@slot(slot other)' }), return i +'@slot(slot other)' }),
'' ] }, '' ]} },
slot_hidden_shown: function(assert){ slot_hidden_shown: function(assert){
var ins = this.slot_hidden(assert) var ins = this.slot_hidden(assert)
var expect = ins.pop() var expect = ins.pop()
return [ return {code: [
...ins.map(function(i){ ...ins.map(function(i){
return i +'@slot(slot shown)' }), return i +'@slot(slot shown)' }),
'' ] }, '' ]} },
//*/ //*/
}) })
@ -105,16 +111,22 @@ test.Modifiers({
test.Tests({ test.Tests({
parse: function(assert, state){ parse: function(assert, state){
var {page, code, st} = state
page ??= {}
st ??= {}
var res var res
var inputs = state.slice(0, -1) var inputs = code.slice(0, -1)
var expect = state.at(-1) var expect = code.at(-1)
var i = 0 var i = 0
for(var input of inputs){ for(var input of inputs){
var p = serialize.partialDeepCopy(page)
var s = serialize.partialDeepCopy(st)
assert( assert(
(res = parser.parse( (res = parser.parse(
{}, p,
input, input,
{})) s))
=== expect, === expect,
'Parsing:', 'Parsing:',
'\n\t in: "'+ input +'"', '\n\t in: "'+ input +'"',