probably using list.sort is okay?
This commit is contained in:
parent
3ac606d0b2
commit
afaedeea23
|
|
@ -454,31 +454,11 @@ describe('enumerables', () => {
|
|||
|
||||
describe('dict operations', () => {
|
||||
test('dict.keys returns all keys', async () => {
|
||||
const result = await (async () => {
|
||||
const { Compiler } = await import('#compiler/compiler')
|
||||
const { run, fromValue } = await import('reefvm')
|
||||
const { setGlobals } = await import('#parser/tokenizer')
|
||||
setGlobals(Object.keys(globals))
|
||||
const c = new Compiler('dict.keys [a=1 b=2 c=3]')
|
||||
const r = await run(c.bytecode)
|
||||
return fromValue(r)
|
||||
})()
|
||||
// Check that all expected keys are present (order may vary)
|
||||
expect(result.sort()).toEqual(['a', 'b', 'c'])
|
||||
await expect(`dict.keys [a=1 b=2 c=3] | list.sort`).toEvaluateTo(['a', 'b', 'c'].sort())
|
||||
})
|
||||
|
||||
test('dict.values returns all values', async () => {
|
||||
const result = await (async () => {
|
||||
const { Compiler } = await import('#compiler/compiler')
|
||||
const { run, fromValue } = await import('reefvm')
|
||||
const { setGlobals } = await import('#parser/tokenizer')
|
||||
setGlobals(Object.keys(globals))
|
||||
const c = new Compiler('dict.values [a=1 b=2]')
|
||||
const r = await run(c.bytecode)
|
||||
return fromValue(r)
|
||||
})()
|
||||
// Check that all expected values are present (order may vary)
|
||||
expect(result.sort()).toEqual([1, 2])
|
||||
await expect('dict.values [a=1 b=2] | list.sort').toEvaluateTo([1, 2].sort())
|
||||
})
|
||||
|
||||
test('dict.has? checks for key', async () => {
|
||||
|
|
@ -489,6 +469,7 @@ describe('dict operations', () => {
|
|||
test('dict.get retrieves value with default', async () => {
|
||||
await expect(`dict.get [a=1] 'a' 0`).toEvaluateTo(1)
|
||||
await expect(`dict.get [a=1] 'b' 99`).toEvaluateTo(99)
|
||||
await expect(`dict.get [a=1] 'b'`).toEvaluateTo(null)
|
||||
})
|
||||
|
||||
test('dict.set sets value', async () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user