@@ -540,7 +540,8 @@ fn parse_parameter_assignment(
540540 let ( name_node, value_node) = extract_name_value_nodes ( node, "parameter assignment" ) ?;
541541
542542 // Parse parameter name (parameter_name is just an identifier)
543- let param_name = source. get_text ( & name_node) ;
543+ // Normalize British spellings (colour -> color) just like MAPPING clauses
544+ let param_name = normalise_aes_name ( & source. get_text ( & name_node) ) ;
544545
545546 // Parse parameter value (parameter_value wraps the actual value node)
546547 let param_value = if let Some ( value_child) = value_node. child ( 0 ) {
@@ -3525,4 +3526,75 @@ mod tests {
35253526 let specs = result. unwrap ( ) ;
35263527 assert_eq ! ( specs[ 0 ] . layers[ 0 ] . position, Position :: dodge( ) ) ;
35273528 }
3529+
3530+ // ========================================
3531+ // Parameter Name Normalization Tests
3532+ // ========================================
3533+
3534+ #[ test]
3535+ fn test_parameter_colour_normalized_to_color ( ) {
3536+ let query = r#"
3537+ VISUALISE
3538+ DRAW point MAPPING x AS x, y AS y SETTING colour => 'red'
3539+ "# ;
3540+
3541+ let result = parse_test_query ( query) ;
3542+ assert ! ( result. is_ok( ) ) ;
3543+ let specs = result. unwrap ( ) ;
3544+
3545+ // "colour" should be normalized to "color"
3546+ assert ! ( specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "color" ) ) ;
3547+ assert ! ( !specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "colour" ) ) ;
3548+ // Color names are converted to hex codes during parsing
3549+ assert_eq ! (
3550+ specs[ 0 ] . layers[ 0 ] . parameters. get( "color" ) ,
3551+ Some ( & ParameterValue :: String ( "#ff0000" . to_string( ) ) )
3552+ ) ;
3553+ }
3554+
3555+ #[ test]
3556+ fn test_parameter_col_normalized_to_color ( ) {
3557+ let query = r#"
3558+ VISUALISE
3559+ DRAW point MAPPING x AS x, y AS y SETTING col => 'blue'
3560+ "# ;
3561+
3562+ let result = parse_test_query ( query) ;
3563+ assert ! ( result. is_ok( ) ) ;
3564+ let specs = result. unwrap ( ) ;
3565+
3566+ // "col" should be normalized to "color"
3567+ assert ! ( specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "color" ) ) ;
3568+ assert ! ( !specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "col" ) ) ;
3569+ // Color names are converted to hex codes during parsing
3570+ assert_eq ! (
3571+ specs[ 0 ] . layers[ 0 ] . parameters. get( "color" ) ,
3572+ Some ( & ParameterValue :: String ( "#0000ff" . to_string( ) ) )
3573+ ) ;
3574+ }
3575+
3576+ #[ test]
3577+ fn test_parameter_mixed_with_colour ( ) {
3578+ let query = r#"
3579+ VISUALISE
3580+ DRAW point MAPPING x AS x, y AS y SETTING colour => 'green', opacity => 0.5
3581+ "# ;
3582+
3583+ let result = parse_test_query ( query) ;
3584+ assert ! ( result. is_ok( ) ) ;
3585+ let specs = result. unwrap ( ) ;
3586+
3587+ // "colour" normalized to "color", opacity unchanged
3588+ assert ! ( specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "color" ) ) ;
3589+ assert ! ( specs[ 0 ] . layers[ 0 ] . parameters. contains_key( "opacity" ) ) ;
3590+ // Color names are converted to hex codes during parsing
3591+ assert_eq ! (
3592+ specs[ 0 ] . layers[ 0 ] . parameters. get( "color" ) ,
3593+ Some ( & ParameterValue :: String ( "#008000" . to_string( ) ) )
3594+ ) ;
3595+ assert_eq ! (
3596+ specs[ 0 ] . layers[ 0 ] . parameters. get( "opacity" ) ,
3597+ Some ( & ParameterValue :: Number ( 0.5 ) )
3598+ ) ;
3599+ }
35283600}
0 commit comments