Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/r-bridge/data/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import type { FlowrCapability } from './types'
import { flowrCapabilities } from './data'


/** Recursively extract all valid identifiers */
type ExtractAllIds<T extends FlowrCapability> =
type CapabilityIdFilter<T extends FlowrCapability, Filter> = T extends Filter ? T['id'] : never

/** Recursively extract all valid identifiers (which have the given support predicate) */
type ExtractAllIds<T extends FlowrCapability, Filter = FlowrCapability> =
T extends { readonly capabilities: infer U }
? U extends readonly FlowrCapability[]
? (T['id'] | ExtractAllIds<U[number]>)
: T['id']
: T['id']
? (CapabilityIdFilter<T, Filter> | ExtractAllIds<U[number]>)
: CapabilityIdFilter<T, Filter>
: CapabilityIdFilter<T, Filter>

type Capabilities = (typeof flowrCapabilities)['capabilities'][number]
export type FlowrCapabilityId = ExtractAllIds<Capabilities>
export type SupportedFlowrCapabilityId = ExtractAllIds<Capabilities, { readonly supported: 'partial' | 'fully' }>

type PathToCapability = readonly number[]

Expand Down
4 changes: 2 additions & 2 deletions test/functionality/_helper/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { DefaultMap } from '../../../src/util/defaultmap'
import { guard } from '../../../src/util/assert'
import type { FlowrCapabilityId} from '../../../src/r-bridge/data'
import type { SupportedFlowrCapabilityId } from '../../../src/r-bridge/data'
import { getAllCapabilities } from '../../../src/r-bridge/data'

// map flowr ids to the capabilities
Expand All @@ -24,7 +24,7 @@ const uniqueTestId = (() => {
* @param testname - the name of the test (`it`) to be labeled
* @param ids - the capability ids to attach to the test
*/
export function label(testname: string, ...ids: FlowrCapabilityId[]): string {
export function label(testname: string, ...ids: SupportedFlowrCapabilityId[]): string {
// assert ids in array are unique
guard(new Set(ids).size === ids.length, () => `Labels must be unique, but are not for ${JSON.stringify(ids)}`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UnnamedArgumentPrefix } from '../../../../../src/dataflow/v1/internal/p
import { GlobalScope, LocalScope } from '../../../../../src/dataflow/common/environments/scopes'
import { MIN_VERSION_PIPE } from '../../../../../src/r-bridge/lang-4.x/ast/model/versions'
import { label } from '../../../_helper/label'
import type { FlowrCapabilityId } from '../../../../../src/r-bridge/data'
import type { SupportedFlowrCapabilityId } from '../../../../../src/r-bridge/data'

describe('Atomic (dataflow information)', withShell((shell) => {
describe('Uninteresting Leafs', () => {
Expand All @@ -26,7 +26,7 @@ describe('Atomic (dataflow information)', withShell((shell) => {
['NULL', 'null'],
['Inf', 'inf-and-nan'],
['NaN', 'inf-and-nan']
] as [string, FlowrCapabilityId][]) {
] as [string, SupportedFlowrCapabilityId][]) {
assertDataflow(label(input, id), shell, input, new DataflowGraph())
}
})
Expand Down Expand Up @@ -361,8 +361,8 @@ describe('Atomic (dataflow information)', withShell((shell) => {
LocalScope,
initializeCleanEnvironments()
)
assertDataflow(label('define call with multiple args should only be defined by the call-return', 'local-left-assignment', 'named-arguments', 'unnamed-arguments','normal', 'name-normal'),
shell,
assertDataflow(label('define call with multiple args should only be defined by the call-return', 'local-left-assignment', 'named-arguments', 'unnamed-arguments','normal', 'name-normal'),
shell,
'a <- foo(x=3,y,z)',
new DataflowGraph()
.addVertex({ tag: 'variable-definition', id: '0', name: 'a', scope: LocalScope })
Expand Down