# Question about rolling forecast horizon

I'm trying to understand how the rolling forecast example below from Rob Hyndman's blog works. In the final line of the for loop, is fc forecasting horizons into the future beyond the end of test? Or is fc meant to be a forecasted version of test, that could be compared to check for accuracy?

My own goal is to create something similar that would train a model and forecast it several horizons in to the future.

Code:

library("fpp")
library("forecast")

##Multi-step forecasts without re-estimation

h <- 5
train <- window(hsales,end=1989.99)
test <- window(hsales,start=1990)
n <- length(test) - h + 1
fit <- auto.arima(train)
fc <- ts(numeric(n), start=1990+(h-1)/12, freq=12)
for(i in 1:n)
{
x <- window(hsales, end=1989.99 + (i-1)/12)
refit <- Arima(x, model=fit)
fc[i] <- forecast(refit, h=h)\$mean[h]
}


Note that n <- length(test) - h +1. So the in the last iteration of the loop, the last h values of test will be forecasted.