s/tests/BenchmarkInstanceTests.st
changeset 6 25b264cec44e
parent 1 1ab204c5442a
child 10 fde9dc632ffa
equal deleted inserted replaced
5:8669edf62d9b 6:25b264cec44e
    72 
    72 
    73 test_01
    73 test_01
    74 
    74 
    75     | b r |
    75     | b r |
    76 
    76 
    77     b := BenchmarkInstance new instance: self benchmark: #bench_01.
    77     b := BenchmarkInstance new instance:self selector:#'bench_01'.
    78     r := b run.
    78     r := b run.
    79 
    79 
    80     self assert: r outcomes size == 1.
    80     self assert: r outcomes size == 1.
    81     self assert: r outcomes first instance == b.
    81     self assert: r outcomes first instance == b.
    82     self assert: log asArray = #(#bench_setUp #bench_01 "default warmup" #bench_01).
    82     self assert: log asArray = #(#bench_setUp #bench_01 "default warmup" #bench_01).
    86 !
    86 !
    87 
    87 
    88 test_02
    88 test_02
    89 
    89 
    90     self 
    90     self 
    91         should: [BenchmarkInstance class: self class benchmark: #non_existent_benchmark]
    91         should: [BenchmarkInstance class:self class selector:#'non_existent_benchmark']
    92         raise: Error
    92         raise: Error
    93 
    93 
    94     "Created: / 27-05-2013 / 22:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    94     "Created: / 27-05-2013 / 22:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    95 !
    95 !
    96 
    96 
    97 test_03a
    97 test_03a
    98 
    98 
    99     | b r |
    99     | b r |
   100 
   100 
   101     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   101     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   102     r := b runWith: Dictionary new.
   102     r := b runWith: Dictionary new.
   103 
   103 
   104     self assert: param1 isNil
   104     self assert: param1 isNil
   105 
   105 
   106     "Created: / 28-05-2013 / 00:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   106     "Created: / 28-05-2013 / 00:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   108 
   108 
   109 test_03b
   109 test_03b
   110 
   110 
   111     | b r |
   111     | b r |
   112 
   112 
   113     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   113     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   114     r := b runWith: (Dictionary new at: #param1 put: '1234'; yourself).
   114     r := b runWith: (Dictionary new at: #param1 put: '1234'; yourself).
   115 
   115 
   116     self assert: param1 == 1234
   116     self assert: param1 == 1234
   117 
   117 
   118     "Created: / 28-05-2013 / 00:05:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   118     "Created: / 28-05-2013 / 00:05:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   120 
   120 
   121 test_03c
   121 test_03c
   122 
   122 
   123     | b r |
   123     | b r |
   124 
   124 
   125     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   125     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   126     r := b runWith: (Dictionary new at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
   126     r := b runWith: (Dictionary new at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
   127 
   127 
   128     self assert: param1 == 1234
   128     self assert: param1 == 1234
   129 
   129 
   130     "Created: / 28-05-2013 / 00:05:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   130     "Created: / 28-05-2013 / 00:05:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   132 
   132 
   133 test_03d
   133 test_03d
   134 
   134 
   135     | b r |
   135     | b r |
   136 
   136 
   137     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   137     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   138     r := b runWith: (Dictionary new 
   138     r := b runWith: (Dictionary new 
   139                         at: #'param1' put: '9876'; 
   139                         at: #'param1' put: '9876'; 
   140                         at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
   140                         at: #'BenchmarkInstanceTests#param1' put: '1234'; yourself).
   141 
   141 
   142     self assert: param1 == 1234
   142     self assert: param1 == 1234
   146 
   146 
   147 test_03e
   147 test_03e
   148 
   148 
   149     | b |
   149     | b |
   150 
   150 
   151     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   151     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   152     self should: [
   152     self should: [
   153         b runWith: (Dictionary new 
   153         b runWith: (Dictionary new 
   154                         at: #'param2' put: '5555'; yourself).
   154                         at: #'param2' put: '5555'; yourself).
   155     ] raise: Error.
   155     ] raise: Error.
   156 
   156 
   159 
   159 
   160 test_03f
   160 test_03f
   161 
   161 
   162     | b |
   162     | b |
   163 
   163 
   164     b := BenchmarkInstance new instance: self benchmark: #bench_01.
   164     b := BenchmarkInstance new instance:self selector:#'bench_01'.
   165     self should: [
   165     self should: [
   166         b runWith: (Dictionary new 
   166         b runWith: (Dictionary new 
   167                         at: #'param1' put: 'asdf'; yourself).
   167                         at: #'param1' put: 'asdf'; yourself).
   168     ] raise: Error.
   168     ] raise: Error.
   169 
   169