Created
October 27, 2010 09:14
-
-
Save Asher-/648712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /********************************* | |
| * RARG_parse_PossibleTypeMatch * | |
| *********************************/ | |
| DESCRIBE( RARG_parse_PossibleTypeMatch, "RARG_parse_PossibleTypeMatch( rarg_parse_descriptor_t* parse_descriptor, rarg_possible_match_t* possible_match, VALUE rb_arg )" ) | |
| IT( "tests whether current arg is a given underying type (R_<type> which correspond in name to Ruby's T_<type>, always in caps)" ) | |
| // should succeed | |
| rarg_parse_descriptor_t* parse_descriptor; | |
| VALUE rb_array = rb_ary_new(); | |
| VALUE args[] = { rb_array }; | |
| RT_ParseDescriptor( parse_descriptor, 1, args ); | |
| parse_descriptor->matched_parameter_ptr = & parse_descriptor->matched_parameter_set->parameters; | |
| *parse_descriptor->matched_parameter_ptr = calloc( 1, sizeof( rarg_matched_parameter_t ) ); | |
| VALUE rb_array_match = Qnil; | |
| rarg_possible_match_t* possible_match = R_MatchType( rb_array_match, R_ARRAY ); | |
| BOOL matched = RARG_parse_PossibleTypeMatch( parse_descriptor, | |
| possible_match, | |
| rb_array ); | |
| SHOULD_BE_TRUE( matched ); | |
| // should fail | |
| VALUE rb_string = rb_str_new2( "some string" ); | |
| VALUE args_two[] = { rb_string }; | |
| RT_ParseDescriptor( parse_descriptor, 1, args_two ); | |
| parse_descriptor->matched_parameter_ptr = & parse_descriptor->matched_parameter_set->parameters; | |
| *parse_descriptor->matched_parameter_ptr = calloc( 1, sizeof( rarg_matched_parameter_t ) ); | |
| matched = RARG_parse_PossibleTypeMatch( parse_descriptor, | |
| possible_match, | |
| rb_string ); | |
| SHOULD_BE_FALSE( matched ); | |
| END_IT | |
| END_DESCRIBE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment