mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-16 05:17:33 +08:00
Replace parsing and test libraries
* WIP * WIP * wip * WIP * Several fixes * Tests wip port to playwright * WIP * Fix more tests * Serialization tests fixed * Several fixes for tests * Input options types * Type adjustments * Fix object reference parser * Tests fixes * More tests fixes
This commit is contained in:
@@ -3,16 +3,16 @@ import IEntity from "../entity/IEntity.js"
|
||||
import SerializerFactory from "./SerializerFactory.js"
|
||||
import Utility from "../Utility.js"
|
||||
|
||||
/** @template {SimpleValueType<SimpleValue>} T */
|
||||
/** @template {AttributeConstructor<Attribute>} T */
|
||||
export default class Serializer {
|
||||
|
||||
/** @type {(v: String) => String} */
|
||||
static same = v => v
|
||||
|
||||
/** @type {(entity: SimpleValue, serialized: String) => String} */
|
||||
/** @type {(entity: Attribute, serialized: String) => String} */
|
||||
static notWrapped = (entity, serialized) => serialized
|
||||
|
||||
/** @type {(entity: SimpleValue, serialized: String) => String} */
|
||||
/** @type {(entity: Attribute, serialized: String) => String} */
|
||||
static bracketsWrapped = (entity, serialized) => `(${serialized})`
|
||||
|
||||
/** @param {T} entityType */
|
||||
@@ -43,7 +43,6 @@ export default class Serializer {
|
||||
|
||||
/** @param {ConstructedType<T>} value */
|
||||
write(value, insideString = false) {
|
||||
// @ts-expect-error
|
||||
return this.doWrite(value, insideString)
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ export default class Serializer {
|
||||
*/
|
||||
doRead(value) {
|
||||
let grammar = Grammar.grammarFor(undefined, this.entityType)
|
||||
const parseResult = grammar.parse(value)
|
||||
const parseResult = grammar.run(value)
|
||||
if (!parseResult.status) {
|
||||
throw new Error(`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}.`)
|
||||
}
|
||||
@@ -61,7 +60,7 @@ export default class Serializer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ConstructedType<T> & IEntity} entity
|
||||
* @param {ConstructedType<T>} entity
|
||||
* @param {Boolean} insideString
|
||||
* @returns {String}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user