Machine learning learn to work well on future data distribution?
It has been studied under various names likes Domain Adaptation,   Sample Selection Bias, Co-variate Shift. 

Please go trough this survey paper on Transfer learning. It covers all the possible combination like

1)same distribution for train and test data 

2) Gradual change between train and test distribution 

3) Different but related distribution for train and test 

It'll also give you all the necessary resources required to study further on this topic.