Serializer Test Specifications

Conformance Level: These tests validate conversion of object model back to TON text format.

Overview

The serializer converts a document object model back into TON text format with various formatting options.

Test Cases

SERIALIZER_001: Empty Object

Purpose: Serialize empty object

Input Object: Empty TonObject

Expected Output (Compact): {}

Expected Output (Pretty):

{
}

SERIALIZER_002: Simple Properties

Purpose: Serialize basic properties

Input Object:

  • Property "name" = "John"
  • Property "age" = 30
  • Property "active" = true

Expected Output (Compact):

{name='John',age=30,active=true}

Expected Output (Pretty):

{
    name = 'John',
    age = 30,
    active = true
}

SERIALIZER_003: Special Characters

Purpose: Serialize strings with escape sequences

Input: String with newline, tab, quotes

Expected: Properly escaped output

  • Newline → \n
  • Tab → \t
  • Single quote in single-quoted string → \'
  • Backslash → \\

SERIALIZER_004: Arrays

Purpose: Serialize array values

Input: Array [1, "hello", true, null]

Expected Compact: [1,'hello',true,null]

Expected Pretty: [1, 'hello', true, null]

SERIALIZER_005: Round-Trip Consistency

Purpose: Ensure parse → serialize → parse produces identical object

Test: For any valid TON document D:

  1. Parse D to object O1
  2. Serialize O1 to text T
  3. Parse T to object O2
  4. O1 should equal O2