dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

c-mode-expansions.feature (3483B)


      1 Feature: C-mode expansions
      2   Background:
      3     Given there is no region selected
      4     And I turn on c-mode
      5     And I insert:
      6     """
      7     int main (int argc, char **argv) {
      8       int x = 0;
      9       double y = 1.;
     10       float z = my_function (x, y);
     11       char t = argv [x + 3];
     12 
     13       fun ( (char*)bob, joe );
     14     
     15       int i = 0;
     16       for ( ; i<N ; ++i ) {
     17         doSomething (i);
     18       }
     19     }
     20     """
     21 
     22 
     23 
     24   Scenario: Mark function call (inside function name)
     25     When I place the cursor after "my_fun"
     26     And I press "C-@"
     27     Then the region should be "function"
     28     And I press "C-@"
     29     Then the region should be "my_function"
     30     And I press "C-@"
     31     Then the region should be "my_function (x, y)"
     32 
     33   Scenario: Mark function call (inside arguments)
     34     When I place the cursor after "my_function ("
     35     And I press "C-@"
     36     Then the region should be "x"
     37     And I press "C-u 3 C-@"
     38     Then the region should be "my_function (x, y)"
     39 
     40 
     41 
     42   Scenario: Mark vector access (inside vector name)
     43     When I place the cursor after "char t = ar"
     44     And I press "C-@"
     45     Then the region should be "argv"
     46     And I press "C-@"
     47     Then the region should be "argv [x + 3]"
     48 
     49   Scenario: Mark vector access (inside argument)
     50     When I place the cursor after "argv ["
     51     And I press "C-@"
     52     Then the region should be "x"
     53     And I press "C-u 3 C-@"
     54     Then the region should be "argv [x + 3]"
     55 
     56 
     57 
     58   Scenario: Mark simple statement (before)
     59     When I place the cursor after "double"
     60     And I press "C-@"
     61     Then the region should be "double"
     62     When I press "C-@"
     63     Then the region should be "double y = 1.;"
     64     
     65   Scenario: Mark simple statement (inside)
     66     When I place the cursor before "double"
     67     And I press "C-@"
     68     Then the region should be "double"
     69     When I press "C-@"
     70     Then the region should be "double y = 1.;"
     71 
     72   Scenario: Mark simple statement (at end)
     73     When I place the cursor after "y = 1."
     74     And I press "C-@"
     75     Then the region should be "1."
     76     When I press "C-@"
     77     Then the region should be "double y = 1.;"
     78 
     79 
     80 
     81   Scenario: Mark complex statement (before)
     82     When I place the cursor after "fo"
     83     And I press "C-@"
     84     Then the region should be "for"
     85     And I press "C-@"
     86     Then the region should be "for ( ; i<N ; ++i )"
     87 
     88   Scenario: Mark complex statement (inside)
     89     When I place the cursor after "i<"
     90     And I press "C-@"
     91     Then the region should be "N"
     92     And I press "C-@"
     93     Then the region should be "i<N ;"
     94     And I press "C-u 3 C-@"
     95     Then the region should be "for ( ; i<N ; ++i )"
     96     
     97   Scenario: Mark complex statement (at end)
     98     When I place the cursor after "++"
     99     And I press "C-@"
    100     Then the region should be "i"
    101     And I press "C-u 3 C-@"
    102     Then the region should be "for ( ; i<N ; ++i )"
    103 
    104 
    105 
    106   Scenario: Mark statement-block (inside statement)
    107     When I place the cursor after "fo"
    108     And I press "C-u 2 C-@"
    109     Then the region should be "for ( ; i<N ; ++i )"
    110     And I press "C-@"
    111     Then the region should be:
    112     """
    113     for ( ; i<N ; ++i ) {
    114         doSomething (i);
    115       }
    116     """
    117 
    118   Scenario: Mark statement-block (inside block)
    119     When I place the cursor after "some"
    120     And I press "C-u 5 C-@"
    121     Then the region should be:
    122     """
    123     for ( ; i<N ; ++i ) {
    124         doSomething (i);
    125       }
    126     """
    127 
    128 
    129 
    130   Scenario: Handle consecutive open parens (issue #69)
    131     When I place the cursor after "(char*)"
    132     And I press "C-u 3 C-@"
    133     Then the region should be "( (char*)bob, joe )"