December 20, 2012

Property based testing for unit testers with PropEr – Part 1 «

Property based testing for unit testers with PropEr – Part 1 «: "Eric states his basic expectations as follows:

I can put arbitrary terms into the dictionary as keys
I can put arbitrary terms into the dictionary as values
When I put a value in the dictionary by a key, I can retrieve that same value
When I put a different value in the dictionary by key it does not change other key value pairs.
When I update a value the new value in available by the new key
When a value does not exist a not found exception is created"

'via Blog this'



%%% @author vlad 
%%% @copyright (C) 2012, vlad
%%% @doc
%%%
%%% @end
%%% Created : 17 Dec 2012 by vlad 

-module(erlware_tests).

-compile(export_all).

-ifdef(TEST).

-include_lib("proper/include/proper.hrl").
-include_lib("eunit/include/eunit.hrl").


%% --------------------------------------------------------------------------------
%% Erlware Dictionary
%% --------------------------------------------------------------------------------

%% I can put arbitrary terms into the dictionary as keys
key() -> nat().
    %union([integer(), atom()]).

%% I can put arbitrary terms into the dictionary as values
value() -> nat(). %union([integer(), atom(), binary(), boolean(), string()]).


sym_dict() ->
    ?SIZED(Size,sym_dict(Size)).

sym_dict(0) ->
    {'$call', ec_dictionary, new, [ec_gb_trees]};
sym_dict(Size) ->
    ?LAZY(frequency([
       {1, {'$call', ec_dictionary, remove, [key(), sym_dict(Size - 1)]}},
       {2, {'$call', ec_dictionary, add, [value(), value(), sym_dict(Size - 1)]}}
      ])).

%% Is it realy work?
%% proper_gen:sample(erlware_tests:value()).
%% proper_gen:sample(erlware_tests:key()).
%% proper_gen:sample(erlware_tests:sym_dict()).
%% {ok,D} = proper_gen:pick(erlware_tests:sym_dict(),10).

%% When I put a value in the dictionary by a key, I can retrieve that same value
prop_get_after_add() ->
    ?FORALL({Dict,K,V}, {sym_dict(), key(), value()},
            V =:= ec_dictionary:get(K, ec_dictionary:add(K, V, Dict))
           ).

%% When I put a different value in the dictionary by key it does not change other key value pairs.
prop_add_twice_get_first() ->
    ?FORALL({Dict,K1,V1,K2,V2}, {sym_dict(), key(), value(), key(), value()},
            ?IMPLIES(K1 /= K2,
                     V1 =:= ec_dictionary:get(K1,
                                              ec_dictionary:add(K2, V2,
                                                                ec_dictionary:add(K1, V1, Dict))) 
                    )).

%% When I update a value the new value in available by the new key
prop_update_the_value() ->
    ?FORALL({Dict,K,V1,V2}, {sym_dict(), key(), value(), value()},
                V2 =:= ec_dictionary:get(K,
                                         ec_dictionary:add(K, V2,
                                                           ec_dictionary:add(K, V1, Dict)))
           ).

%% When a value does not exist a not found exception is created
does_not_exist_exception_test() ->
    ?assertThrow(not_found, ec_dictionary:get(42, ec_dictionary:new(ec_gb_trees))). 


-endif. % (TEST).

July 14, 2012

Flow-based programming - Wikipedia, the free encyclopedia

Flow-based programming - Wikipedia, the free encyclopedia:

'via Blog this'

First impression FBP made on me while playing with Lego edition of LabView. I still prefer CPS actor based style to program robots but I found that most of protocol handling can be nicely decomposed in FBP.



This is Umlet (http://www.umlet.com/) palette which you can copy to ../Umlet/palettes/FBP.uxf and use it for your own design.


  8
  
    com.umlet.element.custom.State
    
      8
      24
      104
      64
    
    READ
--
Read
  Masters

    
  
  
    com.umlet.element.Relation
    
      88
      40
      136
      64
    
    lt=->
m1=OUT
m2=IN[0]

    24;24;56;24;56;48;120;48
  
  
    com.umlet.element.custom.State
    
      208
      72
      104
      56
    
    COLLATE
--
Collate
    
  
  
    com.umlet.element.custom.State
    
      8
      112
      104
      64
    
    READ
--
Read
  Details

    
  
  
    com.umlet.element.Relation
    
      88
      88
      136
      72
    
    lt=->
m1=OUT
m2=IN[1]

    24;56;56;56;56;24;120;24
  
  
    com.umlet.element.custom.State
    
      200
      224
      112
      64
    
    PROC
--
Process
 Merged Streams
    
  
  
    com.umlet.element.Relation
    
      232
      104
      40
      136
    
    lt=->
m1=OUT
m2=IN

    24;24;24;120
  
  
    com.umlet.element.custom.State
    
      8
      192
      104
      64
    
    WRITE
--
Write
  New Masters

    
  
  
    com.umlet.element.custom.State
    
      8
      272
      104
      64
    
    REPORT
--
Summary 
 & Errors

    
  
  
    com.umlet.element.Relation
    
      88
      200
      128
      64
    
    lt=->
m1=OUTM
m2=IN

    112;48;88;48;88;24;24;24
  
  
    com.umlet.element.Relation
    
      88
      240
      128
      72
    
    lt=->
m1=OUTSE
m2=IN

    112;24;88;24;88;56;24;56
  



July 6, 2012

Using xrandr and gtf to add a new mode to your X configuration at runtime | arunviswanathan.com

Using xrandr and gtf to add a new mode to your X configuration at runtime | arunviswanathan.com:

'via Blog this'

In case if xrand reports:


DP3 connected 1920x1080+1680+0 (normal left inverted right x axis y axis) 477mm x 268mm
   1920x1080      60.0 +
   1680x1050      60.0

but monitor can not detect signal it is worst to try subj solution.

In my case HP EliteBook -> DP -> Benq BL2400 could not accept  '1920x1080      60.0' but
was convinced via:



xrandr --output LVDS1 --off
xrandr --newmode "1920x1080_59.90"  172.51  1920 2040 2248 2576  1080 1081 1084 1118  -HSync +Vsync
xrandr --addmode DP3 1920x1080_59.90
xrandr --output DP3 --mode 1920x1080_59.90 --rotate normal --output VGA1 --auto --rotate normal --left-of DP3 --pos 0x0



July 5, 2012

GIT tuning from under firewall

This summary is not available. Please click here to view the post.