User Tools

Site Tools


at:tutorial:appendix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
at:tutorial:appendix [2009/01/30 16:21] – *minor tvcutsemat:tutorial:appendix [2020/02/05 21:01] – * elisag
Line 27: Line 27:
 This will execute all ''test*'' methods in the given unit test (in an **undefined** order!), and print out which of the tests succeeded or failed. The ''runTest'' method can optionally take a "reporter" object as an argument, which can be used to implement a custom strategy for reporting success or failure of a unit test. The default reporter object is a text-based UI. This will execute all ''test*'' methods in the given unit test (in an **undefined** order!), and print out which of the tests succeeded or failed. The ''runTest'' method can optionally take a "reporter" object as an argument, which can be used to implement a custom strategy for reporting success or failure of a unit test. The default reporter object is a text-based UI.
  
-Like in JUnit and SUnit, it is possible to define two methods named ''setUp()'' and ''tearDown()'' that are invoked in between //each// individual ''test*'' method. Never rely on the lexical order of your unit test methods for the purposes of initialization, etc.! Unit test methods may be exacuted in an arbitrary order.+Like in JUnit and SUnit, it is possible to define two methods named ''setUp()'' and ''tearDown()'' that are invoked in between //each// individual ''test*'' method. Never rely on the lexical order of your unit test methods for the purposes of initialization, etc.! Unit test methods may be executed in an arbitrary order.
  
 ==== Assertions ==== ==== Assertions ====
Line 392: Line 392:
 The files in the ''at/lang'' directory define custom language features which mostly use AmbientTalk/2's reflective facilities to extend the language. The files in the ''at/lang'' directory define custom language features which mostly use AmbientTalk/2's reflective facilities to extend the language.
  
-==== Futures and Multifutures ==== 
  
-=== Futures ===+ 
 + 
 +==== Futures ====
  
 The module ''/.at.lang.futures'' provides support for futures. Futures have already been described as part of the [[:at:tutorial:actors#futures|concurrency]] section in the tutorial. The module ''/.at.lang.futures'' provides support for futures. Futures have already been described as part of the [[:at:tutorial:actors#futures|concurrency]] section in the tutorial.
Line 417: Line 418:
 </code> </code>
  
-Finally, the futures module also provides some auxiliary functions, of which ''group:'' is often a very useful one. The ''group:'' construct groups a table of futures into a single future which is resolved with a table of values or ruined with an exception:+The ''makeFuture'' function can also take a timeout. If a timeout is given it returns a returns a pair [leaseresolver]  where the lease timer gets immediately activated. If the future is not resolved within the given timeout, the lease expires and ruins the future with a ''TimeoutException''. Note that this means a lease will get parameter-passed rather than the future if given to other actors. 
 + 
 +=== Auxilary functions in the futures module ==== 
 + 
 +The futures module also provides some auxiliary functions, of which ''group:'' is often a very useful one. The ''group:'' construct groups a table of futures into a single future which is resolved with a table of values or ruined with an exception:
  
 <code> <code>
-when: (group: [ a<-m(), b<-n() ]) becomes: { |values|+when: (group: [ a<-m()@FutureMessage, b<-n()@FutureMessage ]) becomes: { |values|
   def [aResult, bResult] := values;   def [aResult, bResult] := values;
   ...   ...
Line 426: Line 431:
 </code> </code>
  
-=== Multifutures ===+Another useful auxilary function is ''future:'' construct which returns a future which is resolved with the value passed to the 'reply' closure: 
 + 
 +<code> 
 +future: { |return| 
 +  // some computation 
 +  return(val) 
 +
 +</code> 
 + 
 +This is actually equivalent to the slightly more verbose code: 
 + 
 +<code> 
 +def [fut,res] := makeFuture(); 
 +try: { // some computation 
 +  res.resolve(val); 
 +} catch: Exception using: { |e| res.ruin(e) } 
 +fut; 
 +</code> 
 + 
 +==== Multifutures ====
  
 The module ''/.at.lang.multifutures'' provides support for multifutures. A multifuture is a future that can be resolved multiple times. We distinguish between 'bounded multifutures', which can be resolved up to a maximum number and 'unbounded multifutures' which have no upper bound. The module ''/.at.lang.multifutures'' provides support for multifutures. A multifuture is a future that can be resolved multiple times. We distinguish between 'bounded multifutures', which can be resolved up to a maximum number and 'unbounded multifutures' which have no upper bound.
Line 653: Line 677:
 ==== Object Inspector ==== ==== Object Inspector ====
  
-The module ''/.at.support.inspector'' implements a graphical object inspector. The module requires ''java.awt'' and ''javax.swing'' support from the underlying JVM running AmbientTalk. To inspect an object ''o'', execute:+The module ''/.demo.inspector'' implements a graphical object inspector. The module requires ''java.awt'' and ''javax.swing'' support from the underlying JVM running AmbientTalk. To inspect an object ''o'', execute:
  
 <code> <code>
-import /.at.support.inspector;+import /.demo.inspector;
 inspect(o); inspect(o);
 </code> </code>
at/tutorial/appendix.txt · Last modified: 2021/09/24 10:28 by elisag