ParserTests.st
author Claus Gittinger <cg@exept.de>
Tue, 13 Nov 2012 14:44:38 +0100
changeset 750 8f7a78bea037
parent 749 97b804d7b9cf
child 897 8c08e9e494ff
permissions -rw-r--r--
class: RegressionTests::ParserTests changed: #setUp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
	      All Rights Reserved
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
 hereby transferred.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
"{ Package: 'exept:regression' }"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
"{ NameSpace: RegressionTests }"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
TestCase subclass:#ParserTests
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
	instanceVariableNames:'mockClass'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
	classVariableNames:''
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	poolDictionaries:''
749
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
    20
	category:'tests-Regression'
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
!ParserTests class methodsFor:'documentation'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
copyright
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
 COPYRIGHT (c) 2006 by eXept Software AG
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	      All Rights Reserved
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
 hereby transferred.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
!ParserTests methodsFor:'accessing'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
mockClass
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    ^ mockClass
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
mockClass:something
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    mockClass := something.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
parserClass
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    ^Parser
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    "Created: / 01-07-2010 / 11:53:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
    "Modified: / 01-07-2010 / 17:38:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
!ParserTests methodsFor:'running'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
setUp
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
    "prepares the testing environment which consists of mock class instance
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
     for sample annotated methods"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    |testClass|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
750
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    65
    Class withoutUpdatingChangesDo:[
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    66
        testClass := self class 
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    67
                    subclass:'AnnotationTestedClass'
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    68
                    classInstanceVariableNames:''
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    69
                    instanceVariableNames:''
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    70
                    classVariableNames:''
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    71
                    poolDictionaries:''.
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    72
    ].
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
    self mockClass:testClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    "Created: / 29-11-2009 / 20:52:00 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    "Modified: / 29-11-2009 / 22:09:27 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
    "Modified: / 12-07-2010 / 09:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
tearDown
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    "release allocated resources for testing environment"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    self mockClass: nil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    "Created: / 29-11-2009 / 20:52:13 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    "Modified: / 29-11-2009 / 22:09:33 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
581
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    88
!ParserTests methodsFor:'smoke test'!
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    89
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    90
testParseAllMethods
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    91
    Smalltalk allClassesDo:[:cls |
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    92
        Transcript showCR:cls.
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    93
        cls instAndClassMethodsDo:[:mthd |
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    94
            Parser parseMethod:mthd source in:mthd mclass
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    95
        ]
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    96
    ].
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    97
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    98
    "Created: / 28-06-2011 / 22:23:43 / cg"
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
    99
! !
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
   100
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
!ParserTests methodsFor:'tests - annotations'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
testAnnotationWithArrayLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
    "Positive testing the structure of unknown annotation definition: the annotation with #(<array>) literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
                        parseMethod:'annotationWithArrayLiteralExample <annotation: #(1 2 3 4)> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
    self assert:(arguments at:1) = #( 1 2 3 4 ).
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
    "Created: / 12-01-2010 / 13:43:19 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
testAnnotationWithByteArrayLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
    "Positive testing the structure of unknown annotation definition: the annotation with #[<byte array>] literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
                        parseMethod:'annotationWithByteArrayLiteralExample <annotation: #[64 128 192]> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
    self assert:(arguments at:1) = #[ 64 128 192 ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
    "Created: / 12-01-2010 / 13:35:36 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
testAnnotationWithCharacterLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
    "Positive testing the structure of unknown annotation definition: the annotation with character literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
                        parseMethod:'annotationWithCharacterLiteralExample <annotation: $A> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
    self assert:(arguments at:1) = $A.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
    "Created: / 12-01-2010 / 13:20:37 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
testAnnotationWithFalseLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
    "Positive testing the structure of unknown annotation definition: the annotation with false literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
                        parseMethod:'annotationWithFalseLiteralExample <annotation: false> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
    self assert:(arguments at:1) = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
    "Created: / 12-01-2010 / 13:13:26 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
testAnnotationWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
    "Negative testing the structure of unknown annotation definition: the annotation with the non-literal argument; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
    |parserState parseErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   261
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   263
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   264
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   265
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   266
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   268
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
                        parseMethod:'annotationWithInvalidArgumentExample <annotation: annotation:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   270
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   272
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   273
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   274
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
    self assert:parserState errorFlag = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
    self assert:parseErrorOccured = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
    "Created: / 12-01-2010 / 13:48:48 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
testAnnotationWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
    "Negative testing the structure of unknown annotation definition: the annotation with valid argument followed by invalid content; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   284
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   285
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   286
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   287
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   288
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   289
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   290
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   291
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   292
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   293
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   294
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   295
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   296
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   297
                        parseMethod:'annotationWithInvalidContentFollowedExample <annotation: #argument #argument> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   298
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   299
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   300
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   301
    self assert:ignorableErrorOccured = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   302
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   303
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   304
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   305
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   306
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   307
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   308
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   309
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   310
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   311
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
    self assert:(arguments at:1) = #argument.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
    "Created: / 12-01-2010 / 13:52:16 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
testAnnotationWithKeywordLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   320
    "Positive testing the structure of unknown annotation definition: the annotation with #<keyword> literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   323
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   324
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   325
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   326
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   327
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   328
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   330
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   331
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   332
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   333
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   334
                        parseMethod:'annotationWithKeywordLiteralExample <annotation: #equals:> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   335
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   336
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   337
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   338
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   339
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   340
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   341
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   342
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   343
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   344
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   345
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   346
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   347
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   348
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   349
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   350
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   351
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   352
    self assert:(arguments at:1) = #equals:.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   353
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   354
    "Created: / 12-01-2010 / 13:30:47 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   355
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   356
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   357
testAnnotationWithMultiKeywordLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   358
    "Positive testing the structure of unknown annotation definition: the annotation with #<multikeyword> literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   359
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   360
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   361
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   362
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   363
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   364
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   365
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   366
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   367
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   368
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   369
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   370
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   371
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   372
                        parseMethod:'annotationWithMultiKeywordLiteralExample <annotation: #equals:from:> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   373
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   374
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   375
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   376
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   377
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   378
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   379
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   380
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   381
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   382
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   383
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   384
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   385
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   386
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   387
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   388
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   389
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   390
    self assert:(arguments at:1) = #equals:from:.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   391
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   392
    "Created: / 12-01-2010 / 13:31:41 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   393
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   394
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   395
testAnnotationWithNegativeNumberLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   396
    "Positive testing the structure of unknown annotation definition: the annotation with negative_number literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   397
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   398
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   399
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   400
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   401
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   402
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   403
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   404
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   405
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   406
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   407
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   408
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   409
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   410
                        parseMethod:'annotationWithNegativeNumberLiteralExample <annotation: -123> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   411
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   412
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   413
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   414
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   415
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   416
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   417
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   418
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   419
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   420
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   421
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   422
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   423
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   424
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   425
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   426
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   427
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   428
    self assert:(arguments at:1) = -123.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   429
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   430
    "Created: / 12-01-2010 / 13:18:46 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   431
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   432
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   433
testAnnotationWithNilLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   434
    "Positive testing the structure of unknown annotation definition: the annotation with nil literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   435
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   436
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   437
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   438
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   439
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   440
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   441
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   442
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   443
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   444
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   445
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   446
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   447
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   448
                        parseMethod:'annotationWithFalseLiteralExample <annotation: nil> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   449
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   450
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   451
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   452
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   453
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   454
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   455
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   456
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   457
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   458
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   459
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   460
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   461
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   462
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   463
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   464
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   465
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   466
    self assert:(arguments at:1) isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   467
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   468
    "Created: / 12-01-2010 / 13:13:59 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   469
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   470
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   471
testAnnotationWithNumberLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   472
    "Positive testing the structure of unknown annotation definition: the annotation with number literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   473
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   474
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   475
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   476
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   477
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   478
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   479
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   480
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   481
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   482
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   483
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   484
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   485
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   486
                        parseMethod:'annotationWithNumberLiteralExample <annotation: 123> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   487
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   488
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   489
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   490
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   491
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   492
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   493
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   494
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   495
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   496
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   497
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   498
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   499
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   500
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   501
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   502
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   503
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   504
    self assert:(arguments at:1) = 123.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   505
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   506
    "Created: / 12-01-2010 / 13:18:15 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   507
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   508
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   509
testAnnotationWithStringLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   510
    "Positive testing the structure of unknown annotation definition: the annotation with string literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   511
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   512
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   513
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   514
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   515
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   516
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   517
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   518
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   519
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   520
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   521
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   522
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   523
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   524
                        parseMethod:'annotationWithCharacterLiteralExample <annotation: ''Hello world!!''> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   525
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   526
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   527
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   528
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   529
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   530
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   531
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   532
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   533
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   534
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   535
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   536
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   537
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   538
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   539
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   540
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   541
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   542
    self assert:(arguments at:1) = 'Hello world!!'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   543
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   544
    "Created: / 12-01-2010 / 13:21:43 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   545
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   546
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   547
testAnnotationWithSymbolLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   548
    "Positive testing the structure of unknown annotation definition: the annotation with #<characters> | #<name> literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   549
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   550
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   551
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   552
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   553
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   554
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   555
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   556
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   557
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   558
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   559
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   560
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   561
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   562
                        parseMethod:'annotationWithSymbolLiteralExample <annotation: #symbol> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   563
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   564
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   565
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   566
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   567
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   568
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   569
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   570
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   571
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   572
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   573
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   574
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   575
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   576
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   577
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   578
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   579
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   580
    self assert:(arguments at:1) = #symbol.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   581
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   582
    "Created: / 12-01-2010 / 13:26:54 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   583
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   584
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   585
testAnnotationWithSymbolLiteral2
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   586
    "Positive testing the structure of unknown annotation definition: the annotation with #<characters> | #<name> literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   587
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   588
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   589
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   590
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   591
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   592
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   593
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   594
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   595
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   596
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   597
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   598
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   599
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   600
                        parseMethod:'annotationWithSymbolLiteralExample <annotation: symbol> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   601
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   602
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   603
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   604
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   605
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   606
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   607
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   608
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   609
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   610
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   611
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   612
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   613
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   614
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   615
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   616
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   617
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   618
    self assert:(arguments at:1) = #symbol.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   619
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   620
    "Created: / 11-07-2010 / 23:00:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   621
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   622
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   623
testAnnotationWithTrueLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   624
    "Positive testing the structure of unknown annotation definition: the annotation with true literal; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   625
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   626
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   627
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   628
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   629
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   630
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   631
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   632
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   633
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   634
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   635
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   636
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   637
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   638
                        parseMethod:'annotationWithTrueLiteralExample <annotation: true> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   639
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   640
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   641
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   642
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   643
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   644
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   645
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   646
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   647
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   648
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   649
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   650
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   651
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   652
    self assert:(annotation at:1) = 'annotation:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   653
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   654
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   655
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   656
    self assert:(arguments at:1) = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   657
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   658
    "Created: / 12-01-2010 / 13:11:22 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   659
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   660
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   661
testCompoundAnnotationLiteral
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   662
    "Positive testing the structure of unknown annotation definition: the annotation is compound of more keywords defining the annotation type; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   663
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   664
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   665
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   666
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   667
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   668
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   669
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   670
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   671
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   672
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   673
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   674
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   675
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   676
                        parseMethod:'compoundAnnotationLiteralExample <annotation: true alt: false> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   677
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   678
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   679
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   680
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   681
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   682
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   683
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   684
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   685
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   686
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   687
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   688
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   689
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   690
    self assert:(annotation at:1) = 'annotation:alt:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   691
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   692
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   693
    self assert:arguments size = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   694
    self assert:(arguments at:1) = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   695
    self assert:(arguments at:2) = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   696
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   697
    "Created: / 12-01-2010 / 13:47:00 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   698
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   699
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   700
testDislocationAfterMethodBody
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   701
    "Negative testing the location of annotation definition: the annotation is situated after MethodSequenceNode; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   702
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   703
    |parserState parseErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   704
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   705
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   706
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   707
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   708
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   709
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   710
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   711
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   712
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   713
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   714
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   715
                        parseMethod:'dislocationInMethodHeaderExample |x| x:=1. ^x. <annotation: #argument>'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   716
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   717
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   718
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   719
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   720
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   721
    self assert:parserState errorFlag = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   722
    self assert:parseErrorOccured = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   723
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   724
    "Created: / 12-01-2010 / 12:42:03 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   725
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   726
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   727
testDislocationInMethodBody
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   728
    "Negative testing the location of annotation definition: the annotation is situated in MethodSequenceNode; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   729
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   730
    |parserState parseErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   731
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   732
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   733
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   734
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   735
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   736
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   737
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   738
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   739
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   740
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   741
                        parseMethod:'dislocationInMethodHeaderExample |x| <annotation: #argument> x:=1. ^x.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   742
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   743
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   744
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   745
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   746
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   747
    self assert:parserState errorFlag = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   748
    self assert:parseErrorOccured = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   749
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   750
    "Created: / 12-01-2010 / 12:31:24 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   751
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   752
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   753
testDislocationInMethodHeader
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   754
    "Negative testing the location of annotation definition: the annotation is situated before <name>|BinaryMethodName|KeywordMethodName; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   755
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   756
    |parserState parseErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   757
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   758
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   759
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   760
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   761
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   762
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   763
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   764
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   765
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   766
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   767
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   768
                        parseMethod:'<annotation: #argument> dislocationInMethodHeaderExample ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   769
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   770
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   771
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   772
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   773
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   774
    self assert:parserState errorFlag = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   775
    self assert:parseErrorOccured = true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   776
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   777
    "Created: / 12-01-2010 / 12:29:46 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   778
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   779
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   780
testEmptyAnnotation
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   781
    "Positive testing the structure of unknown annotation definition: the empty annotation; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   782
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   783
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   784
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   785
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   786
    " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   787
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   788
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   789
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   790
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   791
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   792
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   793
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   794
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   795
                        parseMethod:'emptyAnnotationExample <annotation> |x| x:=1. ^x. '
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   796
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   797
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   798
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   799
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   800
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   801
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   802
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   803
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   804
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   805
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   806
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   807
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   808
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   809
    self assert:(annotation at:1) = 'annotation'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   810
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   811
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   812
    self assert:arguments size = 0.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   813
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   814
    "Created: / 12-01-2010 / 13:08:15 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   815
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   816
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   817
testMultipleAnnotationsInMethod
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   818
    "Positive testing the multiple annotation definition and theirs order: the annotations are situated in defined location; see grammar"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   819
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   820
    |parserState parseErrorOccured annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   821
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   822
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   823
    parseErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   824
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   825
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   826
            parseErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   827
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   828
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   829
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   830
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   831
                        parseMethod:'multipleAnnotationsInMethodExample <annotation1: #argument> <annotation2: #argument> |x| x:=1. ^x.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   832
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   833
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   834
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   835
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   836
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   837
    self assert:parserState errorFlag = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   838
    self assert:parseErrorOccured = false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   839
     " find the annotations record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   840
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   841
    self assert:(parserState annotations size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   842
     " check the first annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   843
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   844
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   845
    self assert:(annotation at:1) = 'annotation1:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   846
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   847
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   848
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   849
    self assert:(arguments at:1) = #argument.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   850
     " check the second annotation defined"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   851
    annotation := parserState annotations at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   852
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   853
    self assert:(annotation at:1) = 'annotation2:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   854
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   855
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   856
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   857
    self assert:(arguments at:1) = #argument.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   858
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   859
    "Created: / 12-01-2010 / 12:47:57 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   860
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   861
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   862
!ParserTests methodsFor:'tests - context'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   863
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   864
testContextWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   865
    "Negative testing the context annotation structure for the no-literal argument"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   866
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   867
    |parserState|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   868
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   869
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   870
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   871
                parseMethod:'contextWithNoArgumentsExample <context: context:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   872
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   873
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   874
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   875
    self assert:parserState == #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   876
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   877
    "Created: / 11-01-2010 / 22:50:54 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   878
    "Modified: / 01-07-2010 / 16:30:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   879
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   880
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   881
testContextWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   882
    "Negative testing the context annotation structure 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   883
     with valid argument followed by invalid content (following literal): <context: #return #return>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   884
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   885
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   886
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   887
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   888
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   889
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   890
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   891
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   892
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   893
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   894
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   895
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   896
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   897
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   898
                        parseMethod:'contextWithInvalidContentFollowedExample <context: #return #return> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   899
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   900
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   901
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   902
    self should:ignorableErrorOccured.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   903
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   904
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   905
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   906
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   907
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   908
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   909
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   910
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   911
    self assert:(annotation at:1) = 'context:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   912
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   913
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   914
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   915
    self assert:(arguments at:1) = #return.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   916
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   917
    "Created: / 09-01-2010 / 13:14:26 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   918
    "Modified: / 11-01-2010 / 23:15:15 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   919
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   920
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   921
testContextWithNoArguments
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   922
    "Negative testing the context annotation structure for the no argument annotation structure <context>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   923
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   924
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   925
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   926
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   927
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   928
                parseMethod:'contextWithNoArgumentsExample <context> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   929
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   930
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   931
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   932
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   933
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   934
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   935
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   936
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   937
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   938
    self assert:(annotation at:1) = 'context'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   939
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   940
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   941
    self assert:arguments size = 0.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   942
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   943
    "Created: / 09-01-2010 / 12:41:53 / Pavel Pospíchal <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   944
    "Modified: / 11-01-2010 / 23:15:24 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   945
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   946
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   947
testStxContext
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   948
    "Testing the context annotation structure used in St/X virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   949
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   950
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   951
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   952
    " create method for annotation testing purpose : GenericException>>raiseRequest"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   953
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   954
                parseMethod:'stxContextExample <context: #return> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   955
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   956
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   957
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   958
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   959
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   960
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   961
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   962
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   963
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   964
    self assert:(annotation at:1) = 'context:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   965
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   966
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   967
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   968
    self assert:(arguments at:1) = #return.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   969
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   970
    "Created: / 29-11-2009 / 09:37:38 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   971
    "Modified: / 11-01-2010 / 22:33:21 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   972
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   973
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   974
!ParserTests methodsFor:'tests - exception'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   975
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   976
testExceptionWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   977
    "Negative testing the exception annotation structure for the no-literal argument"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   978
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   979
    |parserState|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   980
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   981
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   982
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   983
                parseMethod:'exceptionWithInvalidArgumentExample <exception: exception:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   984
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   985
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   986
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   987
    self assert:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   988
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   989
    "Created: / 11-01-2010 / 22:57:43 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   990
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   991
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   992
testExceptionWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   993
    "Negative testing the exception annotation structure 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   994
     with valid argument followed by invalid content (following literal): <exception: #handle #handle>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   995
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   996
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   997
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   998
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   999
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1000
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1001
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1002
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1003
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1004
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1005
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1006
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1007
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1008
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1009
                        parseMethod:'exceptionWithInvalidContentFollowedExample <exception: #handle #handle> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1010
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1011
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1012
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1013
    self should:ignorableErrorOccured.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1014
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1015
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1016
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1017
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1018
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1019
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1020
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1021
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1022
    self assert:(annotation at:1) = 'exception:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1023
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1024
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1025
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1026
    self assert:(arguments at:1) = #handle.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1027
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1028
    "Created: / 11-01-2010 / 23:02:28 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1029
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1030
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1031
testExceptionWithNoArguments
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1032
    "Negative testing the exception annotation structure for the no argument annotation structure <exception>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1033
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1034
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1035
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1036
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1037
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1038
                parseMethod:'exceptionWithNoArgumentsExample <exception> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1039
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1040
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1041
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1042
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1043
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1044
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1045
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1046
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1047
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1048
    self assert:(annotation at:1) = 'exception'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1049
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1050
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1051
    self assert:arguments size = 0.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1052
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1053
    "Created: / 11-01-2010 / 23:06:31 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1054
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1055
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1056
testSt80HandleException
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1057
    "Testing the exception annotation structure used in St-80 virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1058
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1059
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1060
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1061
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1062
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1063
                parseMethod:'st80HandleExceptionExample <exception: #handle> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1064
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1065
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1066
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1067
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1068
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1069
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1070
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1071
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1072
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1073
    self assert:(annotation at:1) = 'exception:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1074
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1075
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1076
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1077
    self assert:(arguments at:1) = #handle.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1078
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1079
    "Created: / 29-11-2009 / 09:36:20 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1080
    "Modified: / 07-12-2009 / 01:38:31 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1081
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1082
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1083
testSt80RaiseException
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1084
    "Testing the exception annotation structure used in St-80 virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1085
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1086
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1087
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1088
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1089
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1090
                parseMethod:'st80RaiseExceptionExample <exception: #raise> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1091
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1092
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1093
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1094
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1095
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1096
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1097
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1098
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1099
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1100
    self assert:(annotation at:1) = 'exception:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1101
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1102
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1103
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1104
    self assert:(arguments at:1) = #raise.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1105
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1106
    "Created: / 29-11-2009 / 22:36:00 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1107
    "Modified: / 12-12-2009 / 21:39:21 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1108
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1109
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1110
testSt80UnwindException
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1111
    "Testing the exception annotation structure used in St-80 virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1112
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1113
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1114
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1115
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1116
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1117
                parseMethod:'st80UnwindExceptionExample <exception: #unwind> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1118
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1119
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1120
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1121
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1122
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1123
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1124
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1125
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1126
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1127
    self assert:(annotation at:1) = 'exception:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1128
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1129
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1130
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1131
    self assert:(arguments at:1) = #unwind.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1132
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1133
    "Created: / 29-11-2009 / 22:36:49 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1134
    "Modified: / 12-12-2009 / 21:39:35 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1135
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1136
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1137
!ParserTests methodsFor:'tests - external function'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1138
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1139
testDolphinExternalFunctionByStdcall
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1140
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1141
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1142
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1143
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1144
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1145
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1146
                parseMethod:'dolphinExternalFunctionByStdcallExample <stdcall: ''hresult CloseThemeData handle''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1147
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1148
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1149
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1150
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1151
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1152
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1153
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1154
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1155
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1156
    self assert:(annotation at:1) = 'stdcall:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1157
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1158
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1159
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1160
    self assert:(arguments at:1) = 'hresult CloseThemeData handle'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1161
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1162
    "Created: / 29-11-2009 / 09:50:11 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1163
    "Modified: / 12-01-2010 / 11:56:15 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1164
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1165
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1166
testSqueakExternalFunctionByApicall
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1167
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1168
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1169
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1170
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1171
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1172
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1173
                parseMethod:'squeakExternalFunctionByApicallExample <apicall: ''long GetCurrentProcessId (void)'' module: ''kernel32.dll''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1174
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1175
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1176
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1177
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1178
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1179
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1180
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1181
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1182
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1183
    self assert:(annotation at:1) = 'apicall:module:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1184
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1185
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1186
    self assert:arguments size = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1187
    self assert:(arguments at:1) = 'long GetCurrentProcessId (void)'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1188
    self assert:(arguments at:2) = 'kernel32.dll'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1189
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1190
    "Created: / 29-11-2009 / 09:49:04 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1191
    "Modified: / 11-01-2010 / 23:29:51 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1192
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1193
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1194
testSqueakExternalFunctionByCdecl
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1195
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1196
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1197
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1198
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1199
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1200
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1201
                parseMethod:'squeakExternalFunctionByCdeclExample <cdecl: ''long fstat (long MacStat* )'' module: ''libc.dylib''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1202
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1203
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1204
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1205
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1206
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1207
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1208
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1209
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1210
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1211
    self assert:(annotation at:1) = 'cdecl:module:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1212
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1213
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1214
    self assert:arguments size = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1215
    self assert:(arguments at:1) = 'long fstat (long MacStat* )'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1216
    self assert:(arguments at:2) = 'libc.dylib'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1217
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1218
    "Created: / 29-11-2009 / 09:49:36 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1219
    "Modified: / 11-01-2010 / 23:18:04 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1220
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1221
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1222
testStVExternalFunctionByApi
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1223
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1224
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1225
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1226
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1227
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1228
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1229
                parseMethod:'stVExternalFunctionByApiExample <api: ''_func _int32 void''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1230
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1231
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1232
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1233
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1234
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1235
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1236
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1237
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1238
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1239
    self assert:(annotation at:1) = 'api:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1240
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1241
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1242
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1243
    self assert:(arguments at:1) = '_func _int32 void'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1244
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1245
    "Created: / 29-11-2009 / 09:47:49 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1246
    "Modified: / 12-12-2009 / 22:08:06 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1247
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1248
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1249
testStVExternalFunctionByOle
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1250
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1251
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1252
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1253
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1254
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1255
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1256
                parseMethod:'stVExternalFunctionByOleExample <ole: ''return varchar2 varchar2''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1257
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1258
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1259
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1260
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1261
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1262
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1263
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1264
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1265
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1266
    self assert:(annotation at:1) = 'ole:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1267
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1268
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1269
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1270
    self assert:(arguments at:1) = 'return varchar2 varchar2'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1271
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1272
    "Created: / 29-11-2009 / 09:48:25 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1273
    "Modified: / 10-12-2009 / 11:18:29 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1274
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1275
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1276
testVwExternalFunctionByC
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1277
    "Testing the external function annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1278
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1279
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1280
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1281
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1282
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1283
                parseMethod:'vwExternalFunctionByCExample <c: ''void func(int x)''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1284
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1285
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1286
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1287
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1288
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1289
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1290
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1291
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1292
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1293
    self assert:(annotation at:1) = 'c:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1294
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1295
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1296
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1297
    self assert:(arguments at:1) = 'void func(int x)'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1298
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1299
    "Created: / 29-11-2009 / 09:46:31 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1300
    "Modified: / 12-12-2009 / 22:08:24 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1301
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1302
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1303
!ParserTests methodsFor:'tests - primitive'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1304
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1305
testNewSTXPrimitive
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1306
    "Testing the primitive annotation structure used in St/X virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1307
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1308
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1309
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1310
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1311
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1312
                parseMethod:'newSTXPrimitiveExample <primitive> ^self'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1313
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1314
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1315
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1316
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1317
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1318
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1319
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1320
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1321
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1322
    self assert:(annotation at:1) = 'primitive'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1323
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1324
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1325
    self assert:arguments size = 0.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1326
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1327
    "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1328
     The primitive specifies method as logic which needs special handling
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1329
     before setting up a stack frame for the method to make it run. The example structure
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1330
     of primitive annotation is following:
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1331
        <primitive>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1332
    "Created: / 29-11-2009 / 09:34:36 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1333
    "Modified: / 06-12-2009 / 21:46:35 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1334
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1335
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1336
testPrimitiveWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1337
    "Negative testing the context annotation structure for the no-literal argument"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1338
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1339
    |parserState|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1340
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1341
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1342
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1343
                parseMethod:'primitiveWithInvalidArgumentExample <primitive: primitive:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1344
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1345
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1346
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1347
    self assert:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1348
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1349
    "Created: / 12-01-2010 / 08:40:28 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1350
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1351
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1352
testPrimitiveWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1353
    "Negative testing the primitive annotation structure 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1354
     with valid argument followed by invalid content (following literal): <context: #return #return>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1355
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1356
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1357
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1358
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1359
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1360
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1361
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1362
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1363
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1364
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1365
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1366
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1367
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1368
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1369
                        parseMethod:'primitiveWithInvalidContentFollowedExample <primitive: ''test'' ''test''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1370
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1371
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1372
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1373
    self should:ignorableErrorOccured.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1374
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1375
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1376
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1377
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1378
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1379
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1380
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1381
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1382
    self assert:(annotation at:1) = 'primitive:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1383
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1384
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1385
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1386
    self assert:(arguments at:1) = 'test'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1387
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1388
    "Created: / 12-01-2010 / 08:42:01 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1389
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1390
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1391
testSqueakPrimitive
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1392
    "Testing the named primitive annotation structure used in Squeak virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1393
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1394
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1395
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1396
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1397
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1398
                parseMethod:'squeakPrimitiveExample <primitive: ''test''> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1399
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1400
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1401
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1402
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1403
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1404
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1405
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1406
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1407
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1408
    self assert:(annotation at:1) = 'primitive:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1409
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1410
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1411
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1412
    self assert:(arguments at:1) = 'test'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1413
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1414
    "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1415
     The named primitive specifies identifier value used to look up logic which is processed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1416
     before setting up a stack frame for the method to make it run. The example structure
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1417
     of named primitive annotation is following:
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1418
        <primitive: test>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1419
    "Created: / 29-11-2009 / 09:34:05 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1420
    "Modified: / 07-12-2009 / 01:29:29 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1421
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1422
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1423
testSt80Primitive
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1424
    "Testing the numbered primitive annotation structure used in ST-80 virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1425
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1426
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1427
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1428
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1429
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1430
                parseMethod:'st80PrimitiveExample <primitive: 1> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1431
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1432
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1433
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1434
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1435
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1436
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1437
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1438
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1439
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1440
    self assert:(annotation at:1) = 'primitive:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1441
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1442
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1443
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1444
    self assert:(arguments at:1) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1445
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1446
    "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1447
     The numbered primitive specifies index value used to look up logic which is processed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1448
     before setting up a stack frame for the method to make it run. The example structure
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1449
     of numbered primitive annotation is following:
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1450
        <primitive: 1>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1451
    "Created: / 29-11-2009 / 09:33:18 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1452
    "Modified: / 07-12-2009 / 01:20:27 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1453
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1454
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1455
testVAgePrimitive
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1456
    "Testing the named primitive annotation structure used in Visual Age virtual machine"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1457
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1458
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1459
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1460
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1461
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1462
                parseMethod:'vAgePrimitiveExample <primitive: #test> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1463
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1464
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1465
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1466
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1467
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1468
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1469
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1470
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1471
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1472
    self assert:(annotation at:1) = 'primitive:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1473
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1474
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1475
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1476
    self assert:(arguments at:1) = #test.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1477
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1478
    "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1479
     The named primitive specifies identifier value used to look up logic which is processed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1480
     before setting up a stack frame for the method to make it run. The example structure
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1481
     of named primitive annotation is following:
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1482
        <primitive: test>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1483
    "Created: / 29-11-2009 / 09:34:59 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1484
    "Modified: / 12-12-2009 / 22:09:48 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1485
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1486
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1487
!ParserTests methodsFor:'tests - resource'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1488
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1489
testResourceWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1490
    "Negative testing the context annotation structure for the no-literal argument"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1491
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1492
    |parserState|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1493
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1494
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1495
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1496
                parseMethod:'resourceWithInvalidArgumentExample <resource: resource:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1497
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1498
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1499
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1500
    self assert:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1501
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1502
    "Created: / 12-01-2010 / 11:28:13 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1503
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1504
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1505
testResourceWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1506
    "Negative testing the resource annotation structure 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1507
     with valid argument followed by invalid content (following literal): <resource: #symbol #(array of symbols)>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1508
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1509
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1510
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1511
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1512
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1513
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1514
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1515
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1516
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1517
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1518
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1519
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1520
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1521
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1522
                        parseMethod:'resourceWithInvalidContentFollowedExample <resource: #symbol #(1 2 3)> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1523
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1524
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1525
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1526
    self should:ignorableErrorOccured.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1527
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1528
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1529
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1530
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1531
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1532
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1533
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1534
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1535
    self assert:(annotation at:1) = 'resource:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1536
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1537
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1538
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1539
    self assert:(arguments at:1) = #symbol.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1540
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1541
    "Created: / 12-01-2010 / 11:33:22 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1542
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1543
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1544
testResourceWithNoArguments
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1545
    "Negative testing the resource annotation structure for the no argument annotation structure <resource>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1546
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1547
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1548
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1549
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1550
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1551
                parseMethod:'resourceWithNoArgumentsExample <resource> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1552
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1553
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1554
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1555
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1556
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1557
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1558
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1559
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1560
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1561
    self assert:(annotation at:1) = 'resource'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1562
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1563
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1564
    self assert:arguments size = 0.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1565
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1566
    "Created: / 12-01-2010 / 11:35:21 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1567
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1568
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1569
testSingleResourcePragma
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1570
    "Testing the resource annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1571
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1572
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1573
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1574
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1575
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1576
                parseMethod:'resourcePragmaExample <resource: #skipInDebuggersWalkBack> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1577
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1578
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1579
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1580
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1581
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1582
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1583
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1584
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1585
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1586
    self assert:(annotation at:1) = 'resource:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1587
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1588
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1589
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1590
    self assert:(arguments at:1) = #skipInDebuggersWalkBack.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1591
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1592
    "Created: / 29-11-2009 / 09:40:17 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1593
    "Modified: / 12-12-2009 / 22:10:53 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1594
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1595
749
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1596
!ParserTests methodsFor:'tests - scanner'!
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1597
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1598
test_100_scan_EOLcomment1    
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1599
    |parser|
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1600
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1601
    parser := self parserClass new.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1602
    parser saveComments:true.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1603
    parser
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1604
                parseMethod:'foo
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1605
"/
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1606
1'
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1607
                in:mockClass.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1608
     " check the parser result "
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1609
    self deny:parser isNil.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1610
    self deny:parser == #Error.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1611
    self assert:parser comments size == 1.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1612
    self assert:parser comments first commentString isEmpty.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1613
!
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1614
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1615
test_101_scan_EOLcomment2    
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1616
    |parser|
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1617
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1618
    parser := self parserClass new.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1619
    parser saveComments:true.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1620
    parser
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1621
                parseMethod:'foo
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1622
"/a
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1623
1'
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1624
                in:mockClass.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1625
     " check the parser result "
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1626
    self deny:parser isNil.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1627
    self deny:parser == #Error.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1628
    self assert:parser comments size == 1.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1629
    self assert:parser comments first commentString = 'a'.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1630
!
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1631
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1632
test_102_scan_EOLcomment3    
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1633
    |parser|
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1634
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1635
    parser := self parserClass new.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1636
    parser saveComments:true.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1637
    parser
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1638
                parseMethod:'foo
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1639
"/abc
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1640
1'
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1641
                in:mockClass.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1642
     " check the parser result "
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1643
    self deny:parser isNil.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1644
    self deny:parser == #Error.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1645
    self assert:parser comments size == 1.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1646
    self assert:parser comments first commentString = 'abc'.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1647
!
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1648
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1649
test_110_scan_DelimitedComment1    
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1650
    |parser|
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1651
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1652
    parser := self parserClass new.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1653
    parser saveComments:true.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1654
    parser
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1655
                parseMethod:'foo
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1656
"<<END
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1657
bla
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1658
bla bla
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1659
END
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1660
1'
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1661
                in:mockClass.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1662
     " check the parser result "
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1663
    self deny:parser isNil.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1664
    self deny:parser == #Error.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1665
    self assert:parser comments size == 1.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1666
    self assert:parser comments first commentString = '>>END\bla\bla bla\END\' withCRs.
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1667
! !
97b804d7b9cf class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 581
diff changeset
  1668
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1669
!ParserTests methodsFor:'tests - sysprim'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1670
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1671
testSysPrimitiveWithInvalidArgument
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1672
    "Negative testing the context annotation structure for the no-literal argument"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1673
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1674
    |parserState|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1675
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1676
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1677
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1678
                parseMethod:'sysPrimitiveWithInvalidArgumentExample <sysprim: sysprim:> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1679
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1680
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1681
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1682
    self assert:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1683
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1684
    "Created: / 12-01-2010 / 11:49:19 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1685
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1686
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1687
testSysPrimitiveWithInvalidContentFollowed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1688
    "Negative testing the sysprim annotation structure 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1689
     with valid argument followed by invalid content (following literal):  <sysprim: #none #none>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1690
    "Test Note: based on the previous parser behaviour this type of situation is not considered as serious,
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1691
     it's considered as ignorable, informing requester and proceeding execution"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1692
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1693
    |parserState annotation arguments ignorableErrorOccured|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1694
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1695
    ignorableErrorOccured := false.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1696
     " create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1697
    self parserClass parseErrorSignal 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1698
        handle:[:ex | 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1699
            ignorableErrorOccured := true.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1700
            ex proceed
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1701
        ]
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1702
        do:[
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1703
            parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1704
                        parseMethod:'sysPrimitiveWithInvalidContentFollowedExample <sysprim: #none #none> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1705
                        in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1706
        ].
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1707
     " ignorable error should occured "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1708
    self should:ignorableErrorOccured.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1709
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1710
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1711
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1712
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1713
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1714
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1715
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1716
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1717
    self assert:(annotation at:1) = 'sysprim:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1718
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1719
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1720
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1721
    self assert:(arguments at:1) = #none.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1722
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1723
    "Created: / 12-01-2010 / 11:51:14 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1724
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1725
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1726
testSysPrimitiveWithNoArguments
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1727
    "Negative testing the exception annotation structure for the no argument annotation structure <sysprim>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1728
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1729
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1730
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1731
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1732
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1733
                parseMethod:'sysPrimitiveWithNoArgumentsExample <sysprim> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1734
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1735
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1736
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1737
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1738
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1739
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1740
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1741
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1742
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1743
    self assert:(annotation at:1) = 'sysprim'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1744
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1745
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1746
    self assert:arguments size = 0
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1747
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1748
    "Created: / 12-01-2010 / 11:52:40 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1749
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1750
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1751
testVAgeSysPrimitive
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1752
    "Testing the sysprim annotation structure"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1753
    
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1754
    |parserState annotation arguments|
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1755
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1756
    " create method for annotation testing purpose "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1757
    parserState := self parserClass 
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1758
                parseMethod:'vAgeSysPrimitiveExample <sysprim: #none> ^self.'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1759
                in:mockClass.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1760
     " check the parser result "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1761
    self deny:parserState = #Error.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1762
    self deny:parserState isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1763
     " find the annotation record in parser state "
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1764
    self deny:parserState annotations isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1765
    self assert:(parserState annotations size) = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1766
    annotation := parserState annotations at:1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1767
    self assert:(annotation size) = 2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1768
    self assert:(annotation at:1) = 'sysprim:'.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1769
    arguments := annotation at:2.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1770
    self deny:arguments isNil.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1771
    self assert:arguments size = 1.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1772
    self assert:(arguments at:1) = #none.
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1773
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1774
    "Created: / 29-11-2009 / 09:39:11 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1775
    "Modified: / 12-12-2009 / 22:11:28 / pp <Pavel.Pospichal@gmail.com>"
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1776
! !
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1777
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1778
!ParserTests class methodsFor:'documentation'!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1779
750
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1780
version
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1781
    ^ '$Header$'
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1782
!
8f7a78bea037 class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1783
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1784
version_CVS
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1785
    ^ '$Header$'
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1786
!
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1787
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1788
version_SVN
581
Claus Gittinger <cg@exept.de>
parents: 580
diff changeset
  1789
    ^ '§ Id: ParserTests.st 2014 2010-07-12 08:10:01Z vranyj1  §'
580
1b6e2976cb08 initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
  1790
! !