describe?
This commit is contained in:
parent
df3d483de5
commit
a21ba54ad7
|
|
@ -11,19 +11,6 @@ import { list } from './list'
|
|||
import { math } from './math'
|
||||
import { str } from './str'
|
||||
|
||||
export const colors = {
|
||||
reset: '\x1b[0m',
|
||||
bright: '\x1b[1m',
|
||||
dim: '\x1b[2m',
|
||||
cyan: '\x1b[36m',
|
||||
yellow: '\x1b[33m',
|
||||
green: '\x1b[32m',
|
||||
red: '\x1b[31m',
|
||||
blue: '\x1b[34m',
|
||||
magenta: '\x1b[35m',
|
||||
pink: '\x1b[38;2;255;105;180m'
|
||||
}
|
||||
|
||||
export const globals = {
|
||||
dict,
|
||||
load,
|
||||
|
|
@ -43,6 +30,10 @@ export const globals = {
|
|||
// info
|
||||
type: (v: any) => toValue(v).type,
|
||||
inspect: (v: any) => formatValue(toValue(v)),
|
||||
describe: (v: any) => {
|
||||
const val = toValue(v)
|
||||
return { [val.type]: formatValue(toValue(v)) }
|
||||
},
|
||||
length: (v: any) => {
|
||||
const value = toValue(v)
|
||||
switch (value.type) {
|
||||
|
|
@ -106,6 +97,19 @@ export const globals = {
|
|||
|
||||
}
|
||||
|
||||
export const colors = {
|
||||
reset: '\x1b[0m',
|
||||
bright: '\x1b[1m',
|
||||
dim: '\x1b[2m',
|
||||
cyan: '\x1b[36m',
|
||||
yellow: '\x1b[33m',
|
||||
green: '\x1b[32m',
|
||||
red: '\x1b[31m',
|
||||
blue: '\x1b[34m',
|
||||
magenta: '\x1b[35m',
|
||||
pink: '\x1b[38;2;255;105;180m'
|
||||
}
|
||||
|
||||
export function formatValue(value: Value, inner = false): string {
|
||||
switch (value.type) {
|
||||
case 'string':
|
||||
|
|
|
|||
|
|
@ -186,6 +186,12 @@ describe('introspection', () => {
|
|||
// (we'd need more complex assertion to check the actual format)
|
||||
await expect(`type (inspect 'hello')`).toEvaluateTo('string', globals)
|
||||
})
|
||||
|
||||
test('describe describes values', async () => {
|
||||
// Just test that inspect returns something for now
|
||||
// (we'd need more complex assertion to check the actual format)
|
||||
await expect(`describe 'hello'`).toEvaluateTo({ string: "\u001b[32m'hello\u001b[32m'\u001b[0m" }, globals)
|
||||
})
|
||||
})
|
||||
|
||||
describe('collections', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user