这是对象:
package object beautifier {
private val scientificPattern = """([+-]?\d+(\.\d+)?)([Ee]([+-]?\d+))?""".r
}
测试:
import org.scalatest._ import vu.co.kaiyin.formatting.scientificNotaion.beautifier.scientificPattern
class ScientificNotationSpec extends FlatSpec with Matchers {
"Regex" should "return correct matches" in {
"-4.2e-3" match {
case scientificPattern(coef, _, _, exponent) => {
coef should be (-4.2)
exponent should be (-3)
}
}
}
}
我当然得到了一个错误:
Error:(2, 8) object scientificPattern is not a member of package vu.co.kaiyin.formatting.scientificNotaion.beautifier
import vu.co.kaiyin.formatting.scientificNotaion.beautifier.scientificPattern
^
如何解决这个问题?