Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Jul 26, 2024
1 parent 930f62b commit 833e344
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 0 deletions.
82 changes: 82 additions & 0 deletions nixd/tools/nixd/test/definition/select-package-with.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# RUN: nixd --nixpkgs-expr="{ x.y.meta.position = \"/foo:33\"; }" --lit-test < %s | FileCheck %s

Similar to [package.md](./package.md), but testing that we can do "selection" + "with".
i.e. testing if `with pkgs; [x.y]` works.

<-- initialize(0)

```json
{
"jsonrpc":"2.0",
"id":0,
"method":"initialize",
"params":{
"processId":123,
"rootPath":"",
"capabilities":{
},
"trace":"off"
}
}
```


<-- textDocument/didOpen

```json
{
"jsonrpc":"2.0",
"method":"textDocument/didOpen",
"params":{
"textDocument":{
"uri":"file:///basic.nix",
"languageId":"nix",
"version":1,
"text":"with pkgs; [x.y]"
}
}
}
```

<-- textDocument/definition(2)


```json
{
"jsonrpc":"2.0",
"id":2,
"method":"textDocument/definition",
"params":{
"textDocument":{
"uri":"file:///basic.nix"
},
"position":{
"line": 0,
"character":15
}
}
}
```

```
CHECK: "id": 2,
CHECK-NEXT: "jsonrpc": "2.0",
CHECK-NEXT: "result": {
CHECK-NEXT: "range": {
CHECK-NEXT: "end": {
CHECK-NEXT: "character": 0,
CHECK-NEXT: "line": 33
CHECK-NEXT: },
CHECK-NEXT: "start": {
CHECK-NEXT: "character": 0,
CHECK-NEXT: "line": 33
CHECK-NEXT: }
CHECK-NEXT: },
CHECK-NEXT: "uri": "file:///foo"
CHECK-NEXT: }
```


```json
{"jsonrpc":"2.0","method":"exit"}
```
82 changes: 82 additions & 0 deletions nixd/tools/nixd/test/definition/select-package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# RUN: nixd --nixpkgs-expr="{ x.meta.position = \"/foo:33\"; }" --lit-test < %s | FileCheck %s

Similar to [package.md](./package.md), but testing that we can do "selection".
i.e. testing if `pkgs.x` works.

<-- initialize(0)

```json
{
"jsonrpc":"2.0",
"id":0,
"method":"initialize",
"params":{
"processId":123,
"rootPath":"",
"capabilities":{
},
"trace":"off"
}
}
```


<-- textDocument/didOpen

```json
{
"jsonrpc":"2.0",
"method":"textDocument/didOpen",
"params":{
"textDocument":{
"uri":"file:///basic.nix",
"languageId":"nix",
"version":1,
"text":"pkgs.x"
}
}
}
```

<-- textDocument/definition(2)


```json
{
"jsonrpc":"2.0",
"id":2,
"method":"textDocument/definition",
"params":{
"textDocument":{
"uri":"file:///basic.nix"
},
"position":{
"line": 0,
"character":5
}
}
}
```

```
CHECK: "id": 2,
CHECK-NEXT: "jsonrpc": "2.0",
CHECK-NEXT: "result": {
CHECK-NEXT: "range": {
CHECK-NEXT: "end": {
CHECK-NEXT: "character": 0,
CHECK-NEXT: "line": 33
CHECK-NEXT: },
CHECK-NEXT: "start": {
CHECK-NEXT: "character": 0,
CHECK-NEXT: "line": 33
CHECK-NEXT: }
CHECK-NEXT: },
CHECK-NEXT: "uri": "file:///foo"
CHECK-NEXT: }
```


```json
{"jsonrpc":"2.0","method":"exit"}
```

0 comments on commit 833e344

Please sign in to comment.