CompiledCodeObjectTests.st
changeset 10 588414eaacff
parent 9 40f9438e9de3
child 11 cfe5c9d79fbc
equal deleted inserted replaced
9:40f9438e9de3 10:588414eaacff
    68 ! !
    68 ! !
    69 
    69 
    70 !CompiledCodeObjectTests methodsFor:'tests'!
    70 !CompiledCodeObjectTests methodsFor:'tests'!
    71 
    71 
    72 test_01
    72 test_01
    73     | object |
    73     | object section |
    74     self ensureCompiled: #methodWithConstant.
    74     self ensureCompiled: #methodWithConstant.
    75     object := (self class >> #methodWithConstant) codeObject.
    75     object := (self class >> #methodWithConstant) codeObject.
    76     self assert: object compiledCode == (self class >> #methodWithConstant).
    76     self assert: object compiledCode == (self class >> #methodWithConstant).
    77     self assert: object sections size == 2. "/ No literals no ILC's, only code and special cells
    77     self assert: object sections size == 2. "/ No literals no ILC's, only code and special cells
    78     self assert: object sections first name = '.text'.
       
    79     self assert: object sections first format = SectionFormatText.
       
    80     self assert: object sections second name = '.stx.codeobj.specialcells'.
       
    81     self assert: object sections second format = SectionTypeINTVector.
       
    82 
    78 
       
    79     section := object sectionNamed: '.text'.
       
    80     self assert: section format = SectionFormatText.
       
    81 
       
    82     section := object sectionNamed: '.stx.codeobj.specialcells'. 
       
    83     self assert: section format = SectionFormatINTVector.
       
    84     self assert: section size == 1.
    83 
    85 
    84     self ensureCompiled: #methodWithLiteral.
    86     self ensureCompiled: #methodWithLiteral.
    85     object := (self class >> #methodWithLiteral) codeObject.
    87     object := (self class >> #methodWithLiteral) codeObject.
    86     self assert: object sections size == 3. "/ No ILC's but literals, code and special cells
    88     self assert: object sections size == 3. "/ No ILC's but literals, code and special cells
    87 
    89 
       
    90     section := object sectionNamed: '.text'.
       
    91     section := object sectionNamed: '.stx.codeobj.specialcells'. 
       
    92     section := object sectionNamed: '.stx.codeobj.literals'. 
       
    93     self assert: section format = SectionFormatOBJVector.
       
    94     self assert: section size == 1.
    88 
    95 
    89     self ensureCompiled: #methodWithSend.
    96     self ensureCompiled: #methodWithSend.
       
    97     object := (self class >> #methodWithSend) codeObject.
    90     self assert: object sections size == 3. "/ No literals but ILC, code and special cells
    98     self assert: object sections size == 3. "/ No literals but ILC, code and special cells
       
    99     section := object sectionNamed: '.text'.
       
   100     section := object sectionNamed: '.stx.codeobj.specialcells'. 
       
   101     section := object sectionNamed: '.stx.codeobj.ilcs'. 
       
   102     self assert: section format = SectionFormatILCVector.
       
   103     self assert: section size == 1.
    91 
   104 
    92     "Created: / 06-12-2015 / 00:15:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   105     "Created: / 06-12-2015 / 00:15:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    93     "Modified: / 11-01-2016 / 09:54:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   106     "Modified (format): / 19-01-2016 / 21:39:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    94 ! !
   107 ! !
    95 
   108 
    96 !CompiledCodeObjectTests methodsFor:'utilities'!
   109 !CompiledCodeObjectTests methodsFor:'utilities'!
    97 
   110 
    98 ensureCompiled: selector
   111 ensureCompiled: selector