(programRootParticle)
| 19131 | // todo: remove in favor of custom atom type constructors |
| 19132 | class EnumFromAtomTypesTestParser extends AbstractParsersAtomTestParser { |
| 19133 | _getEnumFromAtomTypes(programRootParticle) { |
| 19134 | const atomTypeIds = this.getAtomsFrom(1) |
| 19135 | const enumGroup = atomTypeIds.join(" ") |
| 19136 | // note: hack where we store it on the program. otherwise has global effects. |
| 19137 | if (!programRootParticle._enumMaps) programRootParticle._enumMaps = {} |
| 19138 | if (programRootParticle._enumMaps[enumGroup]) return programRootParticle._enumMaps[enumGroup] |
| 19139 | const atomIndex = 1 |
| 19140 | const map = {} |
| 19141 | const atomTypeMap = {} |
| 19142 | atomTypeIds.forEach(typeId => (atomTypeMap[typeId] = true)) |
| 19143 | programRootParticle.allTypedAtoms |
| 19144 | .filter(typedAtom => atomTypeMap[typedAtom.type]) |
| 19145 | .forEach(typedAtom => { |
| 19146 | map[typedAtom.atom] = true |
| 19147 | }) |
| 19148 | programRootParticle._enumMaps[enumGroup] = map |
| 19149 | return map |
| 19150 | } |
| 19151 | // todo: remove |
| 19152 | isValid(str, programRootParticle) { |
| 19153 | return this._getEnumFromAtomTypes(programRootParticle)[str] === true |
no test coverage detected