My feeling is that your Windows system is performing like it should and that the problem lies with your OS X system. Using the -> instead of :> causes the immediate evaluation of the right hand side of the rule yielding an expression of the form
StringReplace[a, (StartOfString ~~ Whitespace) | (Whitespace ~~ EndOfString) :> ""] with a still undefined. Since StringReplace expects a string as first argument it balks and generates an error message. It then returns unevaluated. Then the pattern match kicks in, a gets the value "Test2" and evaluation of StringReplace continues, now with the sting "Test2" as argument which works.
In this case the :> is the better choice.
The question should be: why doesn't your Mac version object like the Windows version does (and not the other way around)?
I see a number of options:
- YouOn your Mac version you have set error messages preferences (Edit > Preferences > Evaluation> Message and Warning action) to not print to the input notebook
- You have switched off error messages using
Offsomewhere
You might try on(on your Mac systemMMA) the following and see whether it generates an error message (it should):
Message[StringReplace::strse]