本文整理汇总了TypeScript中Immutable.Map.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.of方法的具体用法?TypeScript Map.of怎么用?TypeScript Map.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Map
的用法示例。
在下文中一共展示了Map.of方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('accepts flattened pairs via of()', () => {
var m: Map<any, any> = Map.of(1, 'a', 2, 'b', 3, 'c');
expect(m.size).toBe(3);
expect(m.get(1)).toBe('a');
expect(m.get(2)).toBe('b');
expect(m.get(3)).toBe('c');
});
示例2: describe
describe("formatter", () => {
let priceMap = Map.of(
215, Set(["mixed fruit", "bubble yum"]),
275, Set(["french fries"]),
335, Set(["side salad"]),
355, Set(["hot wings"]),
420, Set(["mozzarella sticks"]),
580, Set(["sampler plate"])
);
let priceCombinations = Set([
List([215, 215, 215, 215, 215, 215, 215]),
List([215, 355, 355, 580])
]);
let expectedResult = Set([
Set(["7 orders of mixed fruit or bubble yum (at $2.15 each)."]),
Set([
"1 order of mixed fruit or bubble yum (at $2.15 each).",
"1 order of mixed fruit or bubble yum (at $2.15 each).",
"2 orders of hot wings (at $3.55 each).",
"1 order of sampler plate (at $5.80 each)."
])
]);
it("properly formats the supplied data", () => {
let f = new Formatter(priceMap, priceCombinations);
expect(f.getSentences().equals(expectedResult)).toBe(true);
});
});
示例3: InterpreterState
export const createInterpreter = (): InterpreterState => {
const globalEnv: Scope = {
name: '_global_',
parent: undefined,
environment: Map<string, any>()
}
return new InterpreterState({
_done: false,
_isReturned: false,
_result: undefined,
isRunning: true,
frames: Stack.of(0),
scopes: Map.of(0, globalEnv),
errors: List(),
value: undefined,
node: undefined
})
}
示例4: describe
describe("parser", () => {
let testData = `$15.05
mixed fruit,$2.15
vanilla calamari,$2.15
french fries,$2.75
side salad,$3.35
hot wings,$3.55
mozzarella sticks,$4.20
sampler plate,$5.80`;
let expectedResults = Map.of(
215, Set(["mixed fruit", "vanilla calamari"]),
275, Set(["french fries"]),
335, Set(["side salad"]),
355, Set(["hot wings"]),
420, Set(["mozzarella sticks"]),
580, Set(["sampler plate"])
);
it("can determine the desired price from test data", () => {
let p = new Parser(testData);
expect(p.getParserResults().desiredPrice).toBe(1505);
});
it("can create Set of food items from test data", () => {
let p = new Parser(testData);
expect(p.getParserResults().foodEntries.equals(expectedResults)).toEqual(true);
});
it("can parse imported data", () => {
let data = fs.readFileSync("./spec/helpers/menu.txt", "utf-8");
let p = new Parser(data);
expect(p.getParserResults().foodEntries.equals(expectedResults)).toEqual(true);
});
it("can validate data", () => {
expect(Parser.validateData(testData)).toBe(true);
});
});
示例5: parseOneLine
private parseOneLine(line: string): Map<number, string> {
// food name vvvvv|comma|v$v|vvvvv price
let match = line.match(/((?:\w| )+)(?:,)(?:\$)(.*)/);
return Map.of(this.integerifyCash(match[2]), Set([match[1].trim()]));
}
示例6: expect
expect(() => {
Map.of(1, 2, 3);
}).toThrow('Missing value for key: 3');