diff --git a/codex/base/vals/cval/a.go b/codex/base/vals/cval/a.go new file mode 100644 index 0000000..13c4b6a --- /dev/null +++ b/codex/base/vals/cval/a.go @@ -0,0 +1,102 @@ +/* —————————————————————————————————————————————————————————————————————————— + Proyecto WIAWAIW +————————————————————————————————————————————————————————————————————————————— + Fichero a.go + Package cval + Autor Juan V. Navarro juanvnl@activething.com + Creado 07/09/2025 +————————————————————————————————————————————————————————————————————————————— + + LICENSES AND TERMS OF USE + ------------------------- + + This software is licensed under the Elastic License v2.0 (the "License"). + For full terms and additional information regarding permitted and prohibited + uses, please visit: + https://activething.com/wiawiaw/licenses + + You may use, copy, modify, and redistribute this software internally within + your organization for any purpose, including research, development, and + testing, subject to the terms of this License. + + You may NOT, however, use, provide, distribute, or make this software + available to any third party as part of a hosted service, SaaS offering, or + commercial product without first obtaining a commercial license from + Active Thing. + + You may combine this software with other code, provided that such + combination does not circumvent the restrictions of this License. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall + the authors or copyright holders be liable for any claim, damages, or other + liability arising from the use of this software. + +————————————————————————————————————————————————————————————————————————————— + + Web : activething.com | wiawiaw.com + git : g.activething.com | github.com/activething + Correo : dev@activething.com + +————————————————————————————————————————————————————————————————————————————— + No deseo caminar sobre el agua", dijo Siddhartha. + Que los antiguos chamanes se contenten con tales habilidades. + —— Hermann Hesse, Siddhartha +————————————————————————————————————————————————————————————————————————————— + Copyright (c) 2025 Active Thing +————————————————————————————————————————————————————————————————————————————— */ + +package cval + + + +var ( + + ckindNames = []string { + "invalid", + "any", + "bool", + "int", + "int8", + "int16", + "int32", + "int64", + "uint", + "uint8", + "uint16", + "uint32", + "uint64", + "uintptr", + "duration", + "float32", + "float64", + "complex64", + "complex128", + "bigInt", + "hashAlg", + "string", + "uUID", + "bytes", + "stack", + "date", + "cValue", + "reflect", + "object", + "packable", + "context", + "stringer", + "error", + } + + ctypeNames = []string{ + "", + "defer", + "list", + "map", + } + +) + + + diff --git a/codex/base/vals/cval/ckind.go b/codex/base/vals/cval/ckind.go new file mode 100644 index 0000000..e099329 --- /dev/null +++ b/codex/base/vals/cval/ckind.go @@ -0,0 +1,110 @@ +/* —————————————————————————————————————————————————————————————————————————— + Proyecto WIAWAIW +————————————————————————————————————————————————————————————————————————————— + Fichero ckind.go + Package cval + Autor Juan V. Navarro juanvnl@activething.com + Creado 06/09/2025 +————————————————————————————————————————————————————————————————————————————— + + LICENSES AND TERMS OF USE + ------------------------- + + This software is licensed under the Elastic License v2.0 (the "License"). + For full terms and additional information regarding permitted and prohibited + uses, please visit: + https://activething.com/wiawiaw/licenses + + You may use, copy, modify, and redistribute this software internally within + your organization for any purpose, including research, development, and + testing, subject to the terms of this License. + + You may NOT, however, use, provide, distribute, or make this software + available to any third party as part of a hosted service, SaaS offering, or + commercial product without first obtaining a commercial license from + Active Thing. + + You may combine this software with other code, provided that such + combination does not circumvent the restrictions of this License. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall + the authors or copyright holders be liable for any claim, damages, or other + liability arising from the use of this software. + +————————————————————————————————————————————————————————————————————————————— + + Web : activething.com | wiawiaw.com + git : g.activething.com | github.com/activething + Correo : dev@activething.com + +————————————————————————————————————————————————————————————————————————————— + No deseo caminar sobre el agua", dijo Siddhartha. + Que los antiguos chamanes se contenten con tales habilidades. + —— Hermann Hesse, Siddhartha +————————————————————————————————————————————————————————————————————————————— + Copyright (c) 2025 Active Thing +————————————————————————————————————————————————————————————————————————————— */ + +package cval + + + + +const ( + // Tipos de valor/clave (hasta 64 valores) + + CKindInvalid CKind = iota + CKindAny + CKindBool + CKindInt + CKindInt8 + CKindInt16 + CKindInt32 + CKindInt64 + CKindUint + CKindUint8 + CKindUint16 + CKindUint32 + CKindUint64 + CKindUintptr + CKindDuration + CKindFloat32 + CKindFloat64 + CKindComplex64 + CKindComplex128 + CKindBigInt + CKindHashAlg + CKindString + CKindUUID + CKindBytes + CKindStack + CKindDate + CKindCValue + CKindReflect + CKindObject + CKindPackable + CKindContext + CKindStringer + CKindError + + maxCKind // Límite superior (no usar directamente) + + +) + + + + +type CKind uint16 // uint16 para soportar valores desplazados (0x0040, 0x0080, 0x00C0) + + + + +func (t CKind) String() string { + if t < maxCKind { + return ckindNames[t] + } + return ckindNames[0] +} \ No newline at end of file diff --git a/codex/base/vals/cval/cvalue_state.go b/codex/base/vals/cval/cstate.go similarity index 99% rename from codex/base/vals/cval/cvalue_state.go rename to codex/base/vals/cval/cstate.go index 3226fc7..339eef2 100644 --- a/codex/base/vals/cval/cvalue_state.go +++ b/codex/base/vals/cval/cstate.go @@ -1,7 +1,7 @@ /* —————————————————————————————————————————————————————————————————————————— Proyecto WIAWAIW ————————————————————————————————————————————————————————————————————————————— - Fichero cvalue_state.go + Fichero cstate.go Package cval Autor Juan V. Navarro juanvnl@activething.com Creado 05/09/2025 diff --git a/codex/base/vals/cval/ctype.go b/codex/base/vals/cval/ctype.go index 1bd369c..3b2c096 100644 --- a/codex/base/vals/cval/ctype.go +++ b/codex/base/vals/cval/ctype.go @@ -4,7 +4,7 @@ Fichero ctype.go Package cval Autor Juan V. Navarro juanvnl@activething.com - Creado 06/09/2025 + Creado 05/09/2025 ————————————————————————————————————————————————————————————————————————————— LICENSES AND TERMS OF USE @@ -49,61 +49,172 @@ package cval +import "fmt" + +// Package cval defines a compact type system for encoding value types, compound types, and key types +// used in maps within a 16-bit unsigned integer. It consists of two main types: CKind and CType. +// +// CKind represents the base type (or "kind") of a value, such as int, string, bool, etc. It is an +// alias for uint16 and defines a set of enumerated constants (CKindInvalid, CKindInt, CKindString, +// ..., CKindError) that occupy the lower 6 bits (0-5) of a type specification. CKind is used to +// specify the fundamental data type for both values and keys in composite types like maps. +// +// CType represents a complete type specification, encoding three components within a 16-bit uint16: +// - Value type (bits 0-5): The base type of the value, represented by a CKind (e.g., CKindString). +// - Compound type (bits 6-7): The structural type, which can be simple (CTypeSimple), deferred +// (CTypeDefer), list (CTypeList), or map (CTypeMap). This defines whether the type is a single +// value, a deferred value, a list of values, or a map with key-value pairs. +// - Key type (bits 8-13): Used only for maps (CTypeMap), this specifies the base type of the key +// (also a CKind, e.g., CKindInt). For non-map types, these bits must be 0. +// - Bits 14-15: Reserved and must be 0 for valid types. +// +// The relationship between CKind and CType is that CKind defines the atomic building blocks (base +// types), while CType combines these with structural information to describe complex types. For +// example: +// - A simple string is represented as CType(CKindString) with compound type CTypeSimple (0x0000). +// - A list of integers is represented as CType(CKindInt) | CTypeList (0x0080). +// - A map with integer keys and string values is represented as CType(CKindString) | +// (CType(CKindInt) << keyTypeShift) | CTypeMap (0x00C0). +// +// Functions like MakeCType, MakeCTypeList, MakeCTypeMap, and MakeCTypeDefer create CType +// values from CKind inputs, ensuring proper bit alignment. Methods like ValueType and KeyType +// extract the respective CKind components from a CType, while DataType extracts the compound type. +// The IsValid method ensures that a CType is well-formed (valid value type, valid compound type, +// and valid key type for maps). The String methods for CKind and CType provide human-readable +// representations, with CKind.String() returning the base type name (e.g., "string") and +// CType.String() combining the compound type and base types (e.g., "list|int", "map|int&string"). -const ( +const ( + typeSimpleMaxBits = 6 + typeCompoundMaxBits = 2 + + // Máscaras para extraer los bits en CType + valueTypeMask CType = 0x003F // 6 bits (0-5) + compTypeMask CType = 0x00C0 // 2 bits (6-7) + keyTypeMask CType = 0x3F00 // 6 bits (8-13) + + // Desplazamientos (solo para creación, no para lectura) + compoundTypeShift = typeSimpleMaxBits + valueTypeShift = 0 + keyTypeShift = compoundTypeShift + typeCompoundMaxBits ) +const ( + invalidCType = "invalid" +) const ( - // Tipos de valor/clave (hasta 64 valores) - - TypeInvalid CType = iota - TypeAny - TypeBool - TypeInt - TypeInt8 - TypeInt16 - TypeInt32 - TypeInt64 - TypeUint - TypeUint8 - TypeUint16 - TypeUint32 - TypeUint64 - TypeUintptr - TypeDuration - TypeFloat32 - TypeFloat64 - TypeComplex64 - TypeComplex128 - TypeBigInt - TypeHashAlg - TypeString - TypeUUID - TypeBytes - TypeStack - TypeDate - TypeCValue - TypeReflect - TypeObject - TypePackable - TypeContext - TypeStringer - TypeError - - maxValueType // Límite superior (no usar directamente) - - - // Tipos agregados (2 bits, alineados con bits 6-7) - - TypeSimple CType = 0 << 0 // 0x0000 - TypeDefer CType = 1 << 6 // 0x0040 - TypeList CType = 2 << 6 // 0x0080 - TypeMap CType = 3 << 6 // 0x00C0 + + // Tipos compuestos (2 bits, alineados con bits 6-7) + + CTypeSimple CType = 0 << compoundTypeShift // 0x0000 + CTypeDefer CType = 1 << compoundTypeShift // 0x0040 + CTypeList CType = 2 << compoundTypeShift // 0x0080 + CTypeMap CType = 3 << compoundTypeShift // 0x00C0 ) +type CType uint16 + + +// Funciones de creación + +// MakeCType creates a CType for a simple value with the specified base type. +// Returns CType(CKindInvalid) if ctyp is invalid (CKindInvalid or >= maxCKind). +func MakeCType(kind CKind) CType { + if kind == CKindInvalid || kind >= maxCKind { + return CType(CKindInvalid) + } + return CType(kind) & valueTypeMask +} + + +// MakeCTypeList creates a CType for a list with the specified base type. +// Returns CType(CKindInvalid) if ctyp is invalid (CKindInvalid or >= maxCKind). +func MakeCTypeList(kind CKind) CType { + if kind == CKindInvalid || kind >= maxCKind { + return CType(CKindInvalid) + } + return (CType(kind) & valueTypeMask) | CTypeList +} + +// MakeCTypeMap creates a CType for a map with the specified value and key types. +// Returns CType(CKindInvalid) if ctyp or ktyp is invalid (CKindInvalid or >= maxCKind). +func MakeCTypeMap(kind, ktyp CKind) CType { + if kind == CKindInvalid || kind >= maxCKind || ktyp == CKindInvalid || ktyp >= maxCKind { + return CType(CKindInvalid) + } + return (CType(kind) & valueTypeMask) | ((CType(ktyp) & valueTypeMask) << keyTypeShift) | CTypeMap +} + +// MakeCTypeDefer creates a CType for a deferred value with the specified base type. +// Returns CType(CKindInvalid) if ctyp is invalid (CKindInvalid or >= maxCKind). +func MakeCTypeDefer(kind CKind) CType { + if kind == CKindInvalid || kind >= maxCKind { + return CType(CKindInvalid) + } + return (CType(kind) & valueTypeMask) | CTypeDefer +} + + + + +// Métodos para CType + +func (t CType) ValueKind() CKind { return CKind(t & valueTypeMask) } + +func (t CType) KeyKind () CKind { return CKind((t & keyTypeMask) >> keyTypeShift) } + +func (t CType) DataType () CType { return t & compTypeMask } + + +func (t CType) IsSimple () bool { return (t & compTypeMask) == CTypeSimple} + +func (t CType) IsDefer () bool { return (t & compTypeMask) == CTypeDefer } + +func (t CType) IsMap () bool { return (t & compTypeMask) == CTypeMap } + +func (t CType) IsList () bool { return (t & compTypeMask) == CTypeList } + + + +func (t CType) IsValid() bool { + valueType := CKind(t & valueTypeMask) + if valueType == CKindInvalid || valueType >= maxCKind { + return false + } + switch t & compTypeMask { + case CTypeSimple, CTypeDefer, CTypeList: + return t&keyTypeMask == 0 + case CTypeMap: + keyType := CKind((t & keyTypeMask) >> keyTypeShift) + return keyType != CKindInvalid && keyType < maxCKind + default: + return false + } +} + + +func (t CType) Sanitize() CType { + if !t.IsValid() { + return CType(CKindInvalid) + } + return t +} -type CType uint16 // uint16 para soportar valores desplazados (0x0040, 0x0080, 0x00C0) +func (t CType) String() string { + if !t.IsValid() { + return invalidCType + } + switch t & compTypeMask { + case CTypeSimple: + //return fmt.Sprintf("%s|%s", ctypeNames[0],t.ValueKind().String()) + return t.ValueKind().String() + case CTypeDefer : return fmt.Sprintf("%s|%s", ctypeNames[1],t.ValueKind().String()) + case CTypeList : return fmt.Sprintf("%s|%s", ctypeNames[2],t.ValueKind().String()) + case CTypeMap : return fmt.Sprintf("%s|%s&%s", ctypeNames[3],t.KeyKind().String(),t.ValueKind().String()) + default: return invalidCType + } +} diff --git a/codex/base/vals/cval/cvalue_spec.go b/codex/base/vals/cval/cvalue_spec.go deleted file mode 100644 index 7e991a3..0000000 --- a/codex/base/vals/cval/cvalue_spec.go +++ /dev/null @@ -1,170 +0,0 @@ -/* —————————————————————————————————————————————————————————————————————————— - Proyecto WIAWAIW -————————————————————————————————————————————————————————————————————————————— - Fichero cvalue_spec.go - Package cval - Autor Juan V. Navarro juanvnl@activething.com - Creado 05/09/2025 -————————————————————————————————————————————————————————————————————————————— - - LICENSES AND TERMS OF USE - ------------------------- - - This software is licensed under the Elastic License v2.0 (the "License"). - For full terms and additional information regarding permitted and prohibited - uses, please visit: - https://activething.com/wiawiaw/licenses - - You may use, copy, modify, and redistribute this software internally within - your organization for any purpose, including research, development, and - testing, subject to the terms of this License. - - You may NOT, however, use, provide, distribute, or make this software - available to any third party as part of a hosted service, SaaS offering, or - commercial product without first obtaining a commercial license from - Active Thing. - - You may combine this software with other code, provided that such - combination does not circumvent the restrictions of this License. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. In no event shall - the authors or copyright holders be liable for any claim, damages, or other - liability arising from the use of this software. - -————————————————————————————————————————————————————————————————————————————— - - Web : activething.com | wiawiaw.com - git : g.activething.com | github.com/activething - Correo : dev@activething.com - -————————————————————————————————————————————————————————————————————————————— - No deseo caminar sobre el agua", dijo Siddhartha. - Que los antiguos chamanes se contenten con tales habilidades. - —— Hermann Hesse, Siddhartha -————————————————————————————————————————————————————————————————————————————— - Copyright (c) 2025 Active Thing -————————————————————————————————————————————————————————————————————————————— */ - -package cval - - -const ( - typeSimpleMaxBits = 6 - typeCompoundMaxBits = 2 - - // Máscaras para extraer los bits en CValueSpec - valueTypeMask CValueSpec = 0x003F // 6 bits (0-5) - compTypeMask CValueSpec = 0x00C0 // 2 bits (6-7) - keyTypeMask CValueSpec = 0x3F00 // 6 bits (8-13) - - // Desplazamientos (solo para creación, no para lectura) - compoundTypeShift = typeSimpleMaxBits - valueTypeShift = 0 - keyTypeShift = compoundTypeShift + typeCompoundMaxBits - - // Constantes predefinidas para tipos agregados (alineadas con bits 6-7) - compoundNone CValueSpec = 0x0000 // 00 << 6 - compoundDefer = CValueSpec(1) << compoundTypeShift // 01 << 6 = 0x0040 - compoundList = CValueSpec(2) << compoundTypeShift // 10 << 6 = 0x0080 - compoundMap = CValueSpec(3) << compoundTypeShift // 11 << 6 = 0x00C0 -) - - -type CValueSpec uint16 - - - - - -// Funciones de creación - -func MakeCValue(ctyp CType) CValueSpec { - return CValueSpec(ctyp) & valueTypeMask -} - -func MakeCList(ctyp CType) CValueSpec { - return (CValueSpec(ctyp) & valueTypeMask) | compoundList -} - -func MakeCMap(ctyp, ktyp CType) CValueSpec { - return (CValueSpec(ctyp) & valueTypeMask) | ((CValueSpec(ktyp) & valueTypeMask) << keyTypeShift) | compoundMap -} - -func MakeCDeferred(ctyp CType) CValueSpec { - return (CValueSpec(ctyp) & valueTypeMask) | compoundDefer -} - - -// Métodos para CValueSpec - -func (t CValueSpec) ValueType () CType { - // Extrae value type (bits 0-5) con máscara, sin desplazamiento - return CType(t & valueTypeMask) -} - -func (t CValueSpec) KeyType () CType { - // Extrae key type (bits 8-13) con máscara, sin desplazamiento - return CType((t & keyTypeMask) >> keyTypeShift) -} - -func (t CValueSpec) CompoundType() CType { - // Extrae tipo agregado (bits 6-7) con máscara, sin desplazamiento - return CType(t & compTypeMask) -} - -func (t CValueSpec) IsDefer () bool { return (t & compTypeMask) == CValueSpec(TypeDefer) } - -func (t CValueSpec) IsMap () bool { return (t & compTypeMask) == CValueSpec(TypeMap) } - -func (t CValueSpec) IsList () bool { return (t & compTypeMask) == CValueSpec(TypeList) } - - -func (t CValueSpec) IsValid() bool { - valueType := CType(t & valueTypeMask) - // Rechaza TypeInvalid y tipos fuera de rango - if valueType == TypeInvalid || valueType >= maxValueType { - return false - } - switch CType(t & compTypeMask) { - case TypeSimple, TypeDefer, TypeList: - // Para estos tipos, los bits de key (8-13) deben ser 0 - return t&keyTypeMask == 0 - - case TypeMap: - // Para Map, necesita un keyType válido - keyType := CType((t & keyTypeMask) >> keyTypeShift) - return keyType != TypeInvalid && keyType < maxValueType - - default: - // Tipo agregado inválido - return false - } -} - -func (t CValueSpec) IsValid2() bool { - valueType := CType(t & valueTypeMask) // Bits 0-5, sin desplazamiento - if valueType == TypeInvalid { // Rechaza TypeInvalid explícitamente - return false - } - compType := CType(t & compTypeMask) // Bits 6-7, sin desplazamiento - if compType == TypeSimple { - // Para TypeSimple, los bits 8-13 deben ser 0 - return valueType < maxValueType && t&keyTypeMask == 0 - } - if compType == TypeMap { - keyType := t.KeyType() >> keyTypeShift // Desplazamiento solo para validación - return valueType < maxValueType && keyType != TypeInvalid && keyType < maxValueType - } - // Para TypeDefer y TypeList, los bits 8-13 deben ser 0 - return valueType < maxValueType && (compType == TypeDefer || compType == TypeList) && t&keyTypeMask == 0 -} - -func (t CValueSpec) Sanitize() CValueSpec { - if !t.IsValid() { - return CValueSpec(TypeInvalid) - } - return t -} - diff --git a/codex/base/vals/cval/z_ctype_test.go b/codex/base/vals/cval/z_ctype_test.go new file mode 100644 index 0000000..cabc1ba --- /dev/null +++ b/codex/base/vals/cval/z_ctype_test.go @@ -0,0 +1,747 @@ +package cval + +import ( + "testing" +) + +// TestMakeCType verifica la función MakeCType +func TestMakeCType(t *testing.T) { + tests := []struct { + name string + ctyp CKind + expected CType + }{ + { + name: "ValidTypeString", + ctyp: CKindString, + expected: CType(CKindString), + }, + { + name: "ValidTypeInt", + ctyp: CKindInt, + expected: CType(CKindInt), + }, + { + name: "InvalidType", + ctyp: CKindInvalid, + expected: CType(CKindInvalid), + }, + { + name: "OutOfRangeType", + ctyp: maxCKind, + expected: CType(CKindInvalid), + }, + { + name: "ArbitraryInvalidType", + ctyp: CKind(0xFFFF), + expected: CType(CKindInvalid), + }, + { + name: "AggregateTypeAsInput", + ctyp: CKindCValue, + expected: CType(CKindCValue), + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := MakeCType(tt.ctyp) + if result != tt.expected { + t.Errorf("MakeCType(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result) + } + if result&0xC000 != 0 { + t.Errorf("MakeCType(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result) + } + }) + } +} + +// TestMakeCTypeList verifica la función MakeCTypeList +func TestMakeCTypeList(t *testing.T) { + tests := []struct { + name string + ctyp CKind + expected CType + }{ + { + name: "ValidTypeString", + ctyp: CKindString, + expected: CType(CKindString) | CTypeList, + }, + { + name: "ValidTypeInt", + ctyp: CKindInt, + expected: CType(CKindInt) | CTypeList, + }, + { + name: "InvalidType", + ctyp: CKindInvalid, + expected: CType(CKindInvalid), + }, + { + name: "OutOfRangeType", + ctyp: maxCKind, + expected: CType(CKindInvalid), + }, + { + name: "ArbitraryInvalidType", + ctyp: CKind(0xFFFF), + expected: CType(CKindInvalid), + }, + { + name: "AggregateTypeAsInput", + ctyp: CKindCValue, + expected: CType(CKindCValue) | CTypeList, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := MakeCTypeList(tt.ctyp) + if result != tt.expected { + t.Errorf("MakeCTypeList(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result) + } + if result&0xC000 != 0 { + t.Errorf("MakeCTypeList(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result) + } + }) + } +} + +// TestMakeCTypeMap verifica la función MakeCTypeMap +func TestMakeCTypeMap(t *testing.T) { + tests := []struct { + name string + ctyp CKind + ktyp CKind + expected CType + }{ + { + name: "ValidStringInt", + ctyp: CKindString, + ktyp: CKindInt, + expected: CType(CKindString) | CType(CKindInt<>compoundTypeShift) + } + }) + } +} \ No newline at end of file diff --git a/codex/base/vals/cval/z_cvalue_spec_test.go b/codex/base/vals/cval/z_cvalue_spec_test.go deleted file mode 100644 index 96fd088..0000000 --- a/codex/base/vals/cval/z_cvalue_spec_test.go +++ /dev/null @@ -1,552 +0,0 @@ -package cval - -import ( - "testing" -) - -// TestMakeCValue verifica la función MakeCValue -func TestMakeCValue(t *testing.T) { - tests := []struct { - name string - ctyp CType - expected CValueSpec - }{ - { - name: "ValidTypeString", - ctyp: TypeString, - expected: CValueSpec(TypeString), - }, - { - name: "ValidTypeInt", - ctyp: TypeInt, - expected: CValueSpec(TypeInt), - }, - { - name: "InvalidType", - ctyp: TypeInvalid, - expected: CValueSpec(TypeInvalid), - }, - { - name: "OutOfRangeType", - ctyp: TypeError + 1, - expected: CValueSpec(TypeError+1) & valueTypeMask, - }, - { - name: "AggregateTypeAsInput", - ctyp: TypeDefer, - expected: CValueSpec(0), - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := MakeCValue(tt.ctyp) - if result != tt.expected { - t.Errorf("MakeCValue(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result) - } - if result&0xC000 != 0 { - t.Errorf("MakeCValue(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result) - } - }) - } -} - -// TestMakeCList verifica la función MakeCList -func TestMakeCList(t *testing.T) { - tests := []struct { - name string - ctyp CType - expected CValueSpec - }{ - { - name: "ValidTypeString", - ctyp: TypeString, - expected: CValueSpec(TypeString) | compoundList, - }, - { - name: "ValidTypeInt", - ctyp: TypeInt, - expected: CValueSpec(TypeInt) | compoundList, - }, - { - name: "InvalidType", - ctyp: TypeInvalid, - expected: CValueSpec(TypeInvalid) | compoundList, - }, - { - name: "AggregateTypeAsInput", - ctyp: TypeList, - expected: CValueSpec(0) | compoundList, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := MakeCList(tt.ctyp) - if result != tt.expected { - t.Errorf("MakeCList(%v): expected %v (0x%04x), got %v (0x%04x)", tt.ctyp, tt.expected, tt.expected, result, result) - } - if result&0xC000 != 0 { - t.Errorf("MakeCList(%v): bits 14-15 should be 0, got %v (0x%04x)", tt.ctyp, result, result) - } - }) - } -} - -// TestMakeCMap verifica la función MakeCMap -func TestMakeCMap(t *testing.T) { - tests := []struct { - name string - ctyp CType - ktyp CType - expected CValueSpec - }{ - { - name: "ValidStringInt", - ctyp: TypeString, - ktyp: TypeInt, - expected: CValueSpec(TypeString) | CValueSpec(TypeInt<