-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Write tests for each data type, targeting the XML format.
- Axes
- Flags
- Components; each as Bool?
- BinaryString
- Base64
- bool
- Bool
- BrickColor
- Integer
- CoordinateFrame
- Components; each as Float
- Color3
- Integer
- Components; each as Float
- Content
- String?
- Components
- double
- Float
- Faces
- Flags
- Components; each as bool?
- float
- Float
- int
- Integer
- ProtectedString
- Text
- CData
- Ray
- Components; each as Tags
- Origin: Components; each as Float
- Direction: Components; each as Float
- Components; each as Tags
- Object
- String?
- string
- String
- token
- Integer
- UDim
- Components
- Scale as Float
- Offset as Integer
- Components
- UDim2
- Components
- Scale as Float
- Offset as Integer
- Components
- Vector2
- Components; each as Float
- Vector2int16
- Components; each as Integer
- Vector3
- Components; each as Float
- Vector3int16
- Components; each as Integer
- NumberSequence
- FloatSequence
- ColorSequence
- FloatSequence
- NumberRange
- FloatSequence
- Rect2D
- Components; each as Tags
- Components; each as Float
- Components; each as Tags
- PhysicalProperties
- Components; each as Tags
- CustomPhysics as Bool
- Rest as Float
- Components; each as Tags
- Color3uint8
- Integer
- Components; each as Float
- int64
- SharedString
- Base64
- (all)
- Leading and trailing spaces
- The space around tokens may or may not be considered significant, depending on the type. Tests can be generated for each type that reveal how such spacing interacts with each type parser.
- Interactions with combinations of elements
- CData
- Text
- Tag
- Leading and trailing spaces
Parser primitives
Each type is represented by a tag of the form:
<Type name="PropertyName">Content</Type>
Content consists of all the sub-elements of the tag. How they are parsed depends entirely on the type. The content appears to come in one of three forms:
- Text: Tag contains a single text element, which represents the value.
- CData: Tag contains a single CData element, which represents the value.
- Tags: Tag contains a number of sub-tags, which represent the value.
Using these forms, each type is comprised of a number of smaller primitives:
- Bool (Text): A single word token (
trueorfalse). - Integer (Text): A single token comprised of a sequence of digits. May begin with
-to indicate a negative value.- There may be an unsigned version that explicitly disallows negative numbers. This needs to be clarified.
- Float (Text): A single token representing a floating point number.
- String (CData/Text): Parses a CData, if present, or Text otherwise.
- Component (Tags): Parses sub-tags, each of which have their own parser primitive.
- CData (CData): Content read as a string.
- Text (Text): Content read as a string.
- Base64 (Text): Decodes as base64, ignoring whitespace.
- FloatSequence (Text): A sequence of Float tokens, separated by whitespace. The tokens are usually batched together, so an amount of tokens that is a multiple of the batch size may be required.
- Flags (Text): An Integer token, where each bit represents a bool.
Multiple representations
For example, Color3 can be represented by R, G, and B sub-tags, or a single integer.
The decoder accepts each representation, which are distinct enough to be parsed unambiguously.
The encoder chooses a default representation, which may change over time depending on preferences. This is fine as long as all representations can reproduce the exact same value. The representation may also be selected depending on the value. For example, the string type encoder avoids using CData if the string contains ]]>.