我有一个qunit模块,它不允许创建对象的方法来查看全局变量。简化版:
qunit.module("testcases", {
setup: function () {
var globalVar = "something";
}
});
test("test1", function () {
obj = new MyObj({});
obj.execute(); // uses globalVar but doesn't see it
});
如何让obj实例识别globalVar?
我也尝试在test1中定义globalVar,但没有运气。我不想将globalVar放在obj实例上,因为它的execute
函数不检查全局
答案 0 :(得分:0)
如匿名超级用户所述 - 无法在设置功能中使用library(dplyr)
library(stringr)
library(stringdist)
setwd()
# load data
data = c("NY", "New York", "NewYork")
data = toupper(data)
# load state name and abbr.
State.data = read.csv('States.csv')
State = toupper(State.data$State)
Stateabb = as.vector(State.data$Abb)
# match data with state names, misspell of 1 letter is allowed
match = amatch(data, State, maxDist=1)
data[ !is.na(match) ] = Stateabb[ na.omit( match ) ]
,因为它实际上已关闭,因为它的范围